Hi,
Can anybody help me to add a blank row into a datagrid?
Thank you!

Recommended Answers

All 8 Replies

DGV.Rows.add();

But if the datagrid is binded you need to add the row to the datasource, NOT in the DGV

DataTable.rows.add();

DGV.Rows.add();

But if the datagrid is binded you need to add the row to the datasource, NOT in the DGV

DataTable.rows.add();

Could I enquire as to why you would want to do this? Give this a try:

datagrid1.Rows.Add(new object[]{null,null});

I am not sure if this will work but give it a try - let me know how it goes!

Thank you to all for your answers.
My datagrid is binded to an object.
I am adding an new empty collection to the object before to bind it to the datagrid.
I have a new empty row into my datagrid, but now the problem is that the id the item is null and I cannot update or delete it.

Can you help me with that?

Thank you!

Hooraay , I added a new object on Update and Delete procedures and now it works fine.
Thank you for your replay!

What object ?
What Id
What code

Difficult to say anything without a little more details ..

Set the all property of datagrid

BindingContext[datasetname,"table"].newrow();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.