Was researching this but could only find how to use a datagrid which is displaying from a database?

I currently have a for loop which goes through a 2d array and prints out all the things I want into a textbox

but, what I want is to be able to have a table and print the things I want into rows and columns instead. I am new to VB.NET in Java it was just a matter of creating a table and a table model and loading the data through that way but not sure how to do it in .NET

Here is the for loop which I have that goes through my array and I want to display it neatly in a table with rows and columns

Any help would be appreciated...
Thanks

For Each Race In TodaysCard    'Print the card
                    With (Race)
                        Names = .menuPath.Split("\")
                        DisplayLog(.eventDate.TimeOfDay.ToString & " " & .marketId & " " & Names(3) & " - " & .marketName)
                    End With
                Next

What type of control are you trying to add the data to?

Datagridview is a very useful control!

What you want to do is take your array and bind it to a datatable and set the datasource on the datagridview control... As such:

Dim rectArray(,) As Integer = {{1, 2, 3}, {12, 13, 14}, {11, 10, 9}}
        Dim dTable As New DataTable
        'LOOP
        dTable.Columns.Add()      ' You need to make sure you have the correct amount of colums for your 2D array
        dTable.Rows.Add(rectArray(0, 0))
        'END LOOP
        Me.<yourDataGridViewControlname>.DataSource = dTable

HTH's!

Create and configure DataTable instance.

Dim dt as new DataTable
dt.Columns.Add("No",GetType(Integer))
dt.Columns.Add("Name")

dt.Rows.Add(1,"A")

dataGridView1.DataSource=dt

wats the code for displaying data from form to table???in php
tnx

This article has been dead for over six months. Start a new discussion instead.