UserControl issue - creating a property which is a collection of controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H
I have created a custom text box control and custom label control (Both inherited controls from the standard .Net controls

I would like to be able to relate several of the label controls to a single text box control, so that I can have code which automatically clears the labels when I clear the control. I would like to define these labels as a property of the text box control so that I can add 1 or many related labels to the contro

Does anyone know how I would do this

Many thank
Siobhan
 
Hi
I have created a custom text box control and custom label control (Both inherited controls from the standard .Net controls)

I would like to be able to relate several of the label controls to a single text box control, so that I can have code which automatically clears the labels when I clear the control. I would like to define these labels as a property of the text box control so that I can add 1 or many related labels to the control

Does anyone know how I would do this?

Many thanks
Siobhan

Sounds like fun.

How about creating your TextBox with an array of labels as a
parameter:

public MyTextBox(Label[] lables)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

m_lblArray = lables;
}

m_lblArray would be a module wide parameter in the MyTextBox
class. You can then run a foreach over them to clear their text.

If, for instance, they were all on one form or other container
you could construct the class with that container as a parameter
and then run a foreach over the container.
 
Back
Top