c# code below to create a listarray of label controls from the form...I wish to have 100 similar controls on a form (labels - named label_0, label_1 .... label_99)
I have a procedure which takes click events from all these controls. I can interrogate the TAG field (sender.Tag) which has been set with the related number, so I know which control has been clicked on. - What I am then doing is changing the backcolor of that control.
However.... There are times when I will only know the TAG number. How can I find the object so I can change the backcolor ?
In VB6 I would create a control array - but this is not fully supported under VB.Net
PHP Code:private void CreateLabelArray()
{
ArrayList LabelList = new ArrayList() ;
foreach (Control EnumControl in this.Controls)
{
if (EnumControl.GetType().Equals(typeof(Label)))
LabelList.Add( EnumControl );
}
((Label)LabelList[1]).BackColor=Color.BlanchedAlmond ;
}


Reply With Quote