| | |
loop through properties?
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 56
Reputation:
Solved Threads: 0
I'm not quite sure how to tackle this problem. I have a form that displays the properties of a class. I have events for all the properties so the form gets updated automatically when the properties change. However, upon initializing a class, these events do not get called, and so the form starts out blank. What is the best way to program so that when I have a new class, the form displays the class's properties immediately?
(One idea I had was to loop through the properties and call each event... is there a way to loop through class properties in .NET?)
(One idea I had was to loop through the properties and call each event... is there a way to loop through class properties in .NET?)
Last edited by Tekito; Nov 26th, 2008 at 12:55 pm.
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
Sure you can, see the implementation below. This example is a copy/paste code from my project in which I added a class "ValidationInstance" which holds a collection of items which should be checked (or préfilled before the handler IsValid will be raisen).
Dim iPropertyCount As Integer = 0
For Each PropertyItem As PropertyInfo In yourClass.GetType().GetProperties()
Select Case iPropertyCount
Case 1 To 10
'add the properties of this class to then validation instance
Dim strToAdd As String = String.Empty
If Not PropertyItem.GetValue(yourClass, Nothing) = Nothing Then
strToAdd = PropertyItem.GetValue(yourClass, Nothing).ToString()
End If
yourClass.ValidationInstance.ValidateRequired(PropertyItem.Name, _
strToAdd.ToString)
End Select
iPropertyCount += 1
Next Last edited by 4advanced; Nov 26th, 2008 at 2:09 pm.
![]() |
Similar Threads
- Tutorial: Understanding ASP classes (ASP)
- Boot-Loop With Vista Home Premium (Windows Vista and Windows 7)
- Using "variable variables" in Javascript (JavaScript / DHTML / AJAX)
- XP Startup Problem: Infinite Loop (Windows NT / 2000 / XP)
- frustrated newbie needs help (C++)
- How to print out string at random interval (Java)
- try to access Active Directory in .NET -->system.runtime.interopservices.comexception (VB.NET)
- Address Book. (C++)
- Primary Key Issue (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: Trying to speed up GUI response time - Combobox SelectIndexValue event slows down app
- Next Thread: Sending mails in vb.net 1.0
| Thread Tools | Search this Thread |
"crystal .net .net2005 2008 access add advanced application array assignment basic beginner box button buttons center click code combo convert cpu cuesent data database datagrid datagridview designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall forms html image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml





