0

is there a way to have the text in a label scroll horizontally,if the text do not fit into the label...
please help...

3
Contributors
4
Replies
7
Views
5 Years
Discussion Span
Last Post by zifina
0

Scroll text ok, but what did you mean by "if the text do not fit into the label..." ?
ADDED: Text always fits to the label.

Edited by Mitja Bonca: n/a

0

A Label is just that: a Label.
Add some scrollbars to your Form, or put your text in a TextBox and add some scrollbars there.

Edited by ddanbe: n/a

0

I did the code for scrolling text in label.
Take a look at it:

public Form1()
        {
            InitializeComponent();
            label1.Text = "abcde";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            char[] chars = label1.Text.ToCharArray();
            char[] newChar = new char[chars.Length];

            int k = 0;
            for (int j = 0; j < chars.Length; j++)
            {
                if (j + 1 < chars.Length)
                    newChar[j + 1] = chars[j];
                else
                {
                    newChar[k] = chars[j];
                    k++;
                }
            }
            label1.Text = new string(newChar);
        }
0
public Form1()
        {
            InitializeComponent();
            label1.Text = "abcdefg";
        }

       

        private void button1_Click(object sender, EventArgs e)
        {
            char[] chars = label1.Text.ToCharArray();
            //MessageBox.Show(chars[1].ToString());
            char[] newChar = new char[chars.Length];
            int l = chars.Length;
            int k = 0;
            for (int j = 0; j < chars.Length; j++)
            {
                
                if (j+1  < chars.Length)
                    newChar[j ] = chars[j+1];
                else
                {
                    newChar[l-1] = chars[k];
                  //  k++;
                }
            }
            label1.Text = new string(newChar);
        }

thanks a lottt again.... :) mainly MITJA..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.