Thursday, December 27, 2012

Looping through like controls

Here is a simple approach to loop through like controls on a form and set (in this case visible) properties.

arrLabel is an array that holds a reference to all controls of type label.  Switch label for button, datagrid, or whatever you want.

    var arrLabel = The_Form_Ref.All(Label);     

Here we start the looping by declaring a variable equal to the elements in the array.  This its a matter of assigning another variable to the actual label and then toggling its visibility.
                     
    for (var lbl : Element in arrLabel)
        {
            var top_lbl : Label = Label(lbl);
            top_lbl.Visible = true;
           
        }

No comments:

Post a Comment