ChubbyArse Posted June 13, 2003 Posted June 13, 2003 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 Quote
Leaders dynamic_sysop Posted June 13, 2003 Leaders Posted June 13, 2003 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 Quote
*Gurus* divil Posted June 13, 2003 *Gurus* Posted June 13, 2003 You can use Reflection to enumerate over the properties of an object. Look in to TypeDescriptor.GetProperties(). Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.