Click here to Skip to main content
13,801,290 members
Rate this:
 
Please Sign up or sign in to 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 16-Apr-18 5:46am
Updated 16-Apr-18 9:32am
v2
Comments
Maciej Los 16-Apr-18 14:07pm
   
Does your DataGridView component is binded with database?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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:

bindingSource1.DataSource = GetData("Select * From Products");
 dataGridView1.DataSource = bindingSource1;
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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[^]
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.181215.1 | Last Updated 16 Apr 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100