Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

Visually see an object array on my form

Public Structure Something
   Item1 as string
   Item2 as string
End Structure

Dim objThing(20,20) as Something

Listview.datasource = objThing
Listbox.datasource = objThing
gridview.datsource = objthing

What is the best .net object to place on my form so I can actually see all the properties of objThing visually?

There must be a fast .net way to do this.
0
Hepen
Asked:
Hepen
1 Solution
 
Bob LearnedCommented:
You can use the PropertyGrid, but I am not sure if you can use it with a structure.  I don't use structures most of the time, so I haven't tried it.

Bob
0
 
SanclerCommented:
You can use a DataGrid but only if (a) you make objThing a one-dimensional array and (b) revise your structure by giving it properties to expose its items.  This has just worked for me on a form with just one control - DataGrid1

    Public Structure Something
        Public Item1 As String
        Public Item2 As String
        Public ReadOnly Property myitem1() As String
            Get
                Return Item1
            End Get
        End Property
        Public ReadOnly Property myitem2() As String
            Get
                Return Item2
            End Get
        End Property
    End Structure

    Dim objThing(20) As Something

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        'make some dummy data
        For i As Integer = 0 To 20
            Dim ms As Something
            ms.Item1 = "structure" & i.ToString & "item1"
            ms.Item2 = "structure" & i.ToString & "item2"
            objThing(i) = ms
        Next

        DataGrid1.DataSource = objThing

    End Sub

Roger
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now