Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
If there is already to many rows and i have to add more new row & that row contain the data which i have write in textbox. Then how to add that rows with another rows in continue in data grid.

What I have tried:

gridView.Rows.Add(value). Using this it display the row but clear the old rows. I have to append the new rows. But this is not working.
Posted
Updated 16-Apr-18 8:32am
v2
Comments
Maciej Los 16-Apr-18 14:07pm    
Does your DataGridView component is binded with database?

There's a good example at:
DataGridView.DataSource Property (System.Windows.Forms)[^]

You basically need to set your datasource property of your GridView.

There's a complete example there, but the basics are:

C#
bindingSource1.DataSource = GetData("Select * From Products");
 dataGridView1.DataSource = bindingSource1;
 
Share this answer
 
Quote:
gridView.Rows.Add(value). Using this it display the row but clear the old rows. I have to append the new rows. But this is not working.

It's not true! Add Method (System.Windows.Forms)[^] adds new row to the DataGridViewRowCollection. This does not reset previous collection.

If you would like to bind data to DataGridView, please, follow these:
How to: Bind Data to the Windows Forms DataGridView Control | Microsoft Docs[^]
How to: Bind Objects to Windows Forms DataGridView Controls | Microsoft Docs[^]
 
Share this answer
 
Comments
Member 11776570 18-Apr-18 12:01pm    
But it is not working, it is clearing the previous data only showing the new data in gridview. i wan to add new data at last in row of data grid view.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900