Add a new row on a datagrid

Hi I’m trying to create and add a new row on my datagrid. The type of this row is different from all the other rows on my datagrid. It’s like a new header. I already have a header. If there is a way to have multiple headers that would work too. when I try to add a new row inside the datagrid_ItemDataBound() method the first record on my datagrid was not shown.. any help ?
thanks
yellowflameAsked:
Who is Participating?
 
craigwardmanCommented:
Although you can add many tables into one dataset, as far as I know its not possible to have multiple tables as the datasource for one datagrid..

You will need multiple datagrid.. Consider loading them at runtime maybe?
0
 
yellowflameAuthor Commented:
I don’t need to have multiple tables…
0
 
craigwardmanCommented:
The headers of a datagrid represent the column names of the schema of the table which the datagrid represents, in order to have rows which follow a different schema would require a different table, but you cant show both tables in the same grid..

If that is what you were after..

i.e.

Dim table1 as DataTable
Dim table2 as DataTable
Dim allData as DataSet

with table1
 .columns.add("FirstName")
 .columns.add("Surname")
end with

with table2
 .columns.add("Car")
 .columns.add("Colour")
end with

allData.Tables.add(table1)
allData.Tables.add(table2)

DataGridView1.DataSource=allData.DefaultViewManager.CreateDataView(allData.Tables(0))
DataGridView2.DataSource=allData.DefaultViewManager.CreateDataView(allData.Tables(1))

(code untested, so may not compile)

If however, you want to have another row of column headers that fit the same schema as the original data and also all the rows following the header fit the same schema, then you could just insert the header row as a normal row and then change the DefaultCellStyle on that row to make it look different from a normal cell..
0
 
yellowflameAuthor Commented:
i haven't try any of the above code because i don't want to have two datagrids.

thanks a lot for your comments
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.