Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How can I enumerate a control's properties in .Net?

 

I bascially want to do this (vb6 code):

 

*****Start Code*****

ctl = control

strPropName = "value"

 

For each prop in ctl.properties

If propr.name = strPropName

msgbox prop.value

Exit For

End if

Next prop

*****Start End*****

 

Thanks

  • Leaders
Posted

       Dim ctl As Control
       Dim obj As String = "TextBox1"
       For Each ctl In Me.Controls
           If ctl.Name = obj Then
               MsgBox(ctl.Name & Chr(10) & ctl.Text)
           Else
               MsgBox(ctl.Name)
           End If
       Next

 

or if you want to get the controls on your form by Type and list them / get the handles :

       Dim ctl As Control
       For Each ctl In Me.Controls
           If TypeOf ctl Is TextBox Then
               MessageBox.Show("textbox : " & ctl.Handle.ToInt32 & Chr(10) & ctl.Name)
           Else
               MessageBox.Show("other control : " & ctl.Handle.ToInt32 & Chr(10) & ctl.Name)
           End If
       Next

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...