Table on VB.NET - what's as easy to use for windows.forms?

GornHorse

Well-known member
Joined
May 27, 2003
Messages
105
Location
Australia
Hi there,

I have a procedure that works wonders with an web.ui table, however, this obviously wont convert over to any table in windows.forms.

I tried creating a table object and adding it to the controls of the windows form, however, it chucked a stink and advised that i could not add a web.ui control to a windows form.

So, i dont understand the datagrid, because it doesnt appear to do what i want it to, which is read from a 2D array only selected data, and then add the text from the array to a particular cell.

In the datagrid, i cant seem to add cells to rows, and rows to the grid like i can with a table.

Please provide one (or both) of the following answers:

a) what is the equivalent of a web.ui table that can be used with the same functionality (ie, add text to a cell, a cell to a row, and a row to a table) on a windows form?

b) how on earth do i get a datagrid to work so that i can add text to a particular cell and add that cell to a particular row?


For reference, here is the code that i used...


Dim inclenarrayx As Integer
Dim inclenarrayy As Integer
Dim inclenarray As Integer
Dim curritem As String
Dim counternullitems As Integer
While counternullitems < fieldcounterx
curritem = dynArray.GetValue(inclenarrayx, inclenarrayy)
While Not (curritem Is Nothing)
While inclenarrayx < fieldcounterx
tblcell.Text = curritem
inclenarray = inclenarray + 1
inclenarrayx = inclenarrayx + 1
curritem = dynArray.GetValue(inclenarrayx, inclenarrayy)
tblrow.Cells.Add(tblcell)
tblcell = New System.Web.UI.WebControls.TableCell()
End While
tbl.Rows.Add(tblrow)
tblrow = New System.Web.UI.WebControls.TableRow()
inclenarrayy = inclenarrayy + 1
inclenarray = inclenarray + 1
inclenarrayx = 0
curritem = dynArray.GetValue(inclenarrayx, inclenarrayy)
tblrow = New System.Web.UI.WebControls.TableRow()
End While
counternullitems = counternullitems + 1
End While
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.tbl})


Please provide responses in vb.net.


Regards,
Michelle
 
Why dont you use a datatable you can change the text in the cells, add rows to it, and surely add columns when ever you want.

Now to show it use the datagrid control. whenever you change anything with your table set the datasource to the datatable again.

Hope this helps,
 
Back
Top