Reputation:
How to add child rows in datagrid c#.net windows forms?
Upvotes: 0
Views: 1228
Reputation: 1
Firstly sure your data GridView name and create DataTable
DataTable DT= new DataTable();
then also create DataRow
DataRow row = new DataRow();
and last call the add() function Like this:
DT.Rows.Add("ID","Name","Addr","number");
and don't miss to set source on DataGrideView for Showing data :
DataGrideView.DataSource = DT;
Upvotes: 0
Reputation: 50245
If you are looking for a nested table, you'll have to go with a third-party control. The DataGridView doesn't support it.
Upvotes: 0
Reputation: 32233
DataTable myDataTable = new DataTable();
DataGridView myGridView = new DataGridView();
myGridView.DataSource = myDataTable;
DataRow row = myDataTable.Rows.Add(1, 2, 3, 4, 5); //This adds the new row
Upvotes: 0
Reputation: 21323
Usually you bind the datagrid to a dataset. Could you please clarify what you are looking for so that we can get into more detail?
Upvotes: 0
Reputation: 630627
I'm not sure if this is what you're asking, but if you want to append rows you're easiest way is to append them to whatever DataSource you're using before you DataBind()
If this wasn't what you're after, please provide more detail.
Upvotes: 3