PC Review


Reply
Thread Tools Rate Thread

Array of structures

 
 
LR
Guest
Posts: n/a
 
      23rd Nov 2004
Is it possible to use an array of structures as a datasource for a control.

ie

dim structure structtest
dim str1 as string
dim str2 as string
end structure

dim artest() as structtest

how do I use the array as a data source for a list box?


 
Reply With Quote
 
 
 
 
Imran Koradia
Guest
Posts: n/a
 
      23rd Nov 2004
Here's how you can go about this:

Public Structure DataStructure
Private s As String
Public Property Str() As String
Get
Return s
End Get
Set(ByVal Value As String)
s = Value
End Set
End Property
End Structure

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim o(2) As DataStructure
o(0) = New DataStructure
o(0).Str = "Item 1"
o(1) = New DataStructure
o(1).Str = "Item 2"
o(2) = New DataStructure
o(2).Str = "Item 3"
ListBox1.DataSource = o
ListBox1.DisplayMember = "Str"
End Sub


hope that helps..
Imran.


"LR" <(E-Mail Removed)> wrote in message
news:HOLod.32354$(E-Mail Removed)...
> Is it possible to use an array of structures as a datasource for a

control.
>
> ie
>
> dim structure structtest
> dim str1 as string
> dim str2 as string
> end structure
>
> dim artest() as structtest
>
> how do I use the array as a data source for a list box?
>
>



 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      23rd Nov 2004
You can use a class instead of a data structure then bind either an arraylist
or array of the classes to controls like the DataGrid.

"LR" wrote:

> Is it possible to use an array of structures as a datasource for a control.
>
> ie
>
> dim structure structtest
> dim str1 as string
> dim str2 as string
> end structure
>
> dim artest() as structtest
>
> how do I use the array as a data source for a list box?
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I declare an array of structures? Do I use NEW? neuromancer Microsoft VB .NET 1 15th Oct 2010 03:49 PM
multidimensional array of structures =?Utf-8?B?cmFuZHk=?= Microsoft VB .NET 2 28th Oct 2005 03:20 AM
Array of structures in C++ .NET ned Microsoft VC .NET 4 2nd Aug 2005 03:41 PM
how to marshal an array of unmanaged structure into a managed array of structures. amags kumar via .NET 247 Microsoft Dot NET Framework 0 4th Jun 2005 01:55 AM
Re: Array of Structures J.Marsch Microsoft C# .NET 0 6th Jan 2004 05:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 PM.