Hi,
I am using VB.net and Visual Studio 2005 to compile a program for a Pocket PC with MicrosoftR Windows Mobile 2003 Second Edition. What I want to do is to display data on datagrid without selecting data from a database. I know that one way to display data on datagrid is to first select data from database using "sqlCeDataAdapter" and then fill the data into a dataTable of a DataSet. Finally this DataSet is assigned to the DataSource property of this datagrid.
However, now I have three ArrayLists: AL1, AL2 and AL3. In these ArrayLists:
AL1(0) = 3; AL1(1) = 2; AL1(2) =1;
AL2(0) = a; AL2(1) = b; AL2(2) =c;
AL3(0) = x; AL3(1) = y; AL3(2) =z;
The result that I am expecting is: on a datagrid, these data can be displayed like:
3 a x
2 b y
1 c z
So, how can do that Any ideas or any useful hyperlinks
Thanks a lot.

Display data on datagrid without selecting data in database
Wayne McMillan
Hi,
I implement your idea using the following codes, but I have another question: for a row, I have to defind an object. For example:
Dim a As New sample
Dim b As New sampleIn practice, I will use this Pocket PC as scanner. If every scan will create a new row in datagrid, how can I create an object of Sample automatically instead of by hand when I scan a bar code to create a new row on datagrid
Thanks a lot.
Imports System.Collections
Public
Class Form1 Public Class sample Private _AL1 As String Private _AL2 As String Private _AL3 As String Public Property AL1() Get Return _AL1 End Get Set(ByVal value)_AL1 = value
End Set End Property Public Property AL2() Get Return _AL2 End Get Set(ByVal value)_AL2 = value
End Set End Property Public Property AL3() Get Return _AL3 End Get Set(ByVal value)_AL3 = value
End Set End Property End Class Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim arr As New ArrayList() Dim a As New sample Dim b As New samplea.AL1 =
"0"a.AL2 =
"a"a.AL3 =
"x"arr.Add(a)
b.AL1 =
"1"b.AL2 =
"b"b.AL3 =
"y"arr.Add(b)
DataGrid1.DataSource = arr
End SubEnd
ClassDhondtie
I'm not sure what exactly do you mean by "automatically instead of by hand".
Anyway, you can create instance as any times as you need by using New operator. For example:
Dim s As sample
s = New sample ' Do it as many times as needed, perhaps in a loop
arr.Add(s)
Josep Oncins
You'd need to create a class with public properties AL1, AL2 and AL3, that class would represent a row in the grid. Put these classes into ArrayList and set grid's DataSource to it.
Keep in mind it’s way slower than using DataSet as DataSource and there are no automatic updates – each time you add, remove or modify ArrayList you need to rebind.
Joos
hrubesh
Hi,
Thanks a lot for your reply, and could you please write a sample codes for "Create a class with public properties AL1, AL2 and AL3, that class would represent a row in the grid. Put these classes into ArrayList and set grid's DataSource to it. " Thanks a lot in advance.
Best regards.