|
-
Jan 30th, 2011, 10:47 AM
#25
Thread Starter
PowerPoster
Re: Control looping.
thanks, ill check it out.
 Originally Posted by dbasnett
Something to think about...
Code:
Public Class Form1
Dim ctlDict As New Dictionary(Of String, Control)
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'build a dictionary of all controls
Dim ctl As Control = Me.GetNextControl(Me, True) 'Get the first control in the tab order.
Do Until ctl Is Nothing
ctlDict.Add(ctl.Name, ctl)
ctl = Me.GetNextControl(ctl, True) 'Get the next control in the tab order.
Loop
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'query the dictionary of controls
Dim foo As IEnumerable(Of Generic.KeyValuePair(Of String, Control))
foo = From de In ctlDict _
Where de.Key.Contains("Exclude") AndAlso _
TypeOf de.Value Is CheckBox AndAlso _
CType(de.Value, CheckBox).Checked Select de
'the count
Debug.WriteLine(foo.Count.ToString)
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|