none
Append Text To Label RRS feed

  • Question

  • foreach (string s in sca)
    {
    lblProgress.Visible = true;
    lblProgress.ForeColor = System.Drawing.Color.Black;
    lblProgress.Font = new Font(lblNoData.Font.Name, 10, FontStyle.Bold);
    lblProgress.Text = "Now Working On Customer " + s;
    }

    I want the label to auto-expand to read
    Now Working on Customer 1
    Now Working on Customer 2
    Now Working on Customer 3
    Now Working on Customer 4

    and if it fills the screen, add a scrollbar so the user can scroll up/down to see what customer has/has not been processed
    Tuesday, December 12, 2017 6:58 PM

All replies

  • Hi,

    by ItemsControl entries are dynamically extended.

    There can be items generated by associate ItemsSource or items direct:

    ---------------------- snippet -------------------------------

        <ListBox>
            <ListBoxItem>Now Working on Customer 1</ListBoxItem>
            <ListBoxItem>Now Working on Customer 2</ListBoxItem>
            <ListBoxItem>Now Working on Customer 3</ListBoxItem>
            <ListBoxItem>Now Working on Customer 4</ListBoxItem>
        </ListBox>

    -----------------------------------------------------------

    regards, Hubert Hermanutz

    • Proposed as answer by Cor Ligthert Wednesday, December 13, 2017 12:46 PM
    Tuesday, December 12, 2017 7:48 PM
  • Hi,

    by ItemsControl entries are dynamically extended.

    There can be items generated by associate ItemsSource or items direct:

    ---------------------- snippet -------------------------------

        <ListBox>
            <ListBoxItem>Now Working on Customer 1</ListBoxItem>
            <ListBoxItem>Now Working on Customer 2</ListBoxItem>
            <ListBoxItem>Now Working on Customer 3</ListBoxItem>
            <ListBoxItem>Now Working on Customer 4</ListBoxItem>
        </ListBox>

    -----------------------------------------------------------

    regards, Hubert Hermanutz

    Would it be possible to auto-size the listbox as more and more data is added to span to the bottom of the form?

    I have only used a listbox before to show 1 item at a time.

    Tuesday, December 12, 2017 7:50 PM
  • Hello IndigoMontoya,

    If you insist on using lable, you need to create a customer control with scrollbar. If you just want to display text as label. You have many choice to select. For example, try to use TextBox , set the ScrollBars and Readonly property.

    https://stackoverflow.com/questions/2906581/scrollbar-on-a-label

    Or you could try to use ListBox control. This also is a food choice for you.

           string[] sca = new string[] { "1","2","3","4","5","6","7","8","9"};          
                foreach (string s in sca)
                {
    
                    listBox1.Font = new Font("Times New Roman", 10, FontStyle.Bold);
                    listBox1.ForeColor = Color.Black;               
                    listBox1.Items.Add("Now Working On Customer "+s);              
                }

    Best regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Thursday, December 14, 2017 9:49 AM
    Wednesday, December 13, 2017 6:35 AM
    Moderator
  • Hello IndigoMontoya,

    Is there any update or any other assistance I could provide? You could mark the helpful reply as answer if the issue has been solved. And if you have any concerns, please do not hesitate to let us know.

    Thank you for your understanding and patience!

    Best regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Sunday, December 24, 2017 8:31 AM
    Moderator