Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Detect If Control Contains Property

Reply
 
Old 10-14-2008   #1 (permalink)
Derek Hart


 
 

Detect If Control Contains Property

How can I detect if a control contains a property. Need to use reflection
somehow?

If ctl.ContainsProperty("Tag") Then ctl.Tag = "some tag information"



My System SpecsSystem Spec
Old 10-15-2008   #2 (permalink)
Phill W.


 
 

Re: Detect If Control Contains Property

Derek Hart wrote:
Quote:

> How can I detect if a control contains a property.
Why do you need to?

You can /ask/ any Control (or, indeed, any Object) what Type it is, and
then process it accordingly, as in

Sub Click( sender as Object e as EventArgs )

If Typeof sender is CheckBox Then
With DirectCast( sender, CheckBox )
.Text = .Text.ToUpper()
.CheckState = CheckedState.Checked
End With

Else If Typeof sender is TextBox Then
With DirectCast( sender, TextBox )
.Text = .Text.ToLower()
End With

End If
End Sub
Quote:

> Need to use reflection somehow?
If you /really/ must, but it's more difficult and (I would expect) quite
a bit slower as well.

HTH,
Phill W.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Set Focus To Specific Property In Property Grid .NET General
Value under the CPU property? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46