Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using the code

VB.NET
For Each ctl In flowlayoutpanel1.controls
 If TypeOf ctl Is Button Then
      If ctl.Text = dsselectroom.Tables(0).Rows(0).Item(0) Then
              ctl.BackColor = System.Drawing.Color.Plum 
      End If
 End If
Next


Since I have created flowlayoutpanel at runtime, it shows error at

flowlayoutpanel1.controls from the above code.


flowlayoutpanel contains buttons which too i have created at runtime.

i need to check the button text with the value in the database

suggest me
Posted
Updated 5-Mar-10 0:29am
v4

More info please, like the error you are getting.

[ To: Answer Author; This is not an answer, it is a clarification and was asked 20 minutes before you in the message section below! That is what the section is for.]
 
Share this answer
 
v3
I created a new form and added a layout control with the same name as above, then dragged a bunch of controls into the layout panel, labels, buttons, checkboxes, list boxes etc.

I ran the following;
VB.NET
For Each ctl In FlowLayoutPanel1.Controls
        If TypeOf ctl Is Button Then
            'If ctl.Text = dsselectroom.Tables(0).Rows(0).Item(0) Then
            '    ctl.BackColor = System.Drawing.Color.Plum
            'End If
            Debug.WriteLine(ctl.name)
        End If
    Next
End Sub


And the buttons were correctly listed in the debug window. Noticed i commented out the If ctl.text = so may have something to do with dsselectroom
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900