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

Recommended Answers

All 4 Replies

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.

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.

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);
        }
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..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.