dcsimg
Results 1 to 3 of 3

Thread: Change text in multiple labels at once

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    9

    Change text in multiple labels at once

    Hello,

    I'm looking for a way to change text in multiple labels all at once by using a loop instead of changing them individually as this takes a long time and is quite repetitive. Is this possible?

    Thank you.

  2. #2
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,580

    Re: Change text in multiple labels at once

    Yes. There should be numerous results if you search for "control arrays .net". That's basically it. Put your controls in an array, then loop over the array.

    Big mistake that's not obvious until you make it: set up the array in the Load/Shown event, or in Sub New() after InitializeComponent(). If you try to set it up at declaration time, that's when all the control variables are Nothing and you'll be sad.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    9

    Re: Change text in multiple labels at once

    Thank you so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width