UI to enter values into a structure

  • Thread starter Thread starter jim_adams
  • Start date Start date
J

jim_adams

For a nested structure such as:

Dim userVariable as one

structure one
dim a as string
dim b() as two
end structure

structure two
dim c as string
dim d as string
end structure

before I do the monkey work of creating a VB.Net UI for an end user to
fill out values for userVariable, I was wondering if there's a generic
code sample that will take in a structure and provide a dynamic form to
fill out its properties. Although the nested structure I'm working
with is more complex than this example, all data types are either
strings or integers.

Any insight is greatly appreciated.

Thanks,

Jim
 
Hullo Jimbo,
Your best bet is going to lie with the Reflection classes.

Check out the System.Type class... something along the lines of:

Public Structure Foo
Private sSomeString As String

Public Property SomeString As String
Get
Return sSomeString
End Get
Set (byval tValue as String)
sSomeString = tValue
End Set
End Property
End Structure


Public Sub MakeForm()
Dim tInfo as PropertyInfo = Nothing

For Each tInfo in GetType(Foo)
' Do some crap.. make the form field.. etc.
Next

end Sub
 
Back
Top