UI to enter values into a structure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jim_adams@hotmail.com

    #1

    UI to enter values into a structure

    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

  • GhostInAK

    #2
    Re: UI to enter values into a structure

    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

    [color=blue]
    > 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
    >[/color]


    Comment

    • jim_adams@hotmail.com

      #3
      Re: UI to enter values into a structure

      Thanks for your help. This seems like a good idea for a GotDotNet
      project!

      -Jim


      GhostInAK wrote:[color=blue]
      > 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
      >
      >[color=green]
      > > 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
      > >[/color][/color]

      Comment

      Working...