Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Knowing if a property exists
Message
From
02/03/2011 17:00:18
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01502282
Message ID:
01502417
Views:
42
>I (think) the VB version would be something like this:
>
>
>Dim prop = dataSource.GetType().GetProperty(boundField, BindingFlags.IgnoreCase Or BindingFlags.Public Or BindingFlags.Instance)
>If prop <> Nothing Then
>   ' Property exists.
>
>
>You may need to adjust the binding flags, depending on the types of properties you want to check.

I really cannot make that work. I have an object loLabel which is related to the class LabelFunction. So, code looks like this:
Dim loLabel As Framework.LabelFunction = New Framework.LabelFunction(oProcess)

' Get a reference to the property
loPropertyInfo = loLabel.GetType().GetProperty("c" + lcKey, System.Reflection.BindingFlags.IgnoreCase Or _
 System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance)

' If the property exists
If Not loPropertyInfo Is Nothing Then

End If
But, it always execute as the property does not exist. It never gets into the If condition. I verified "c" + lcKey. And, it does say cExportToExcel. In the LabelFunction class, I do have a public property cExportToExcel. I cannot understand what it always say that it is nothing.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform