We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,687 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

DataGridView add row

In DataGridView, how can i input data then add row

3
Contributors
3
Replies
1 Day
Discussion Span
9 Months Ago
Last Updated
4
Views
Question
Answered
brylle
Junior Poster in Training
58 posts since Aug 2012
Reputation Points: -2
Solved Threads: 4
Skill Endorsements: 0

in order to add new row you have to define column in your grid then just add row like this
for example i have to textboxes txtName , txtFatherName and a grid with two columns , name and father name , a button , i want to add new row in my grid by clicking that button. use this code at the click event of the button

datagridview1.rows.add(txtName.text,txtFatherName.text)

this will add row to your grid.

Regards

M.Waqas Aslam
Master Poster
743 posts since Aug 2011
Reputation Points: 50
Solved Threads: 120
Skill Endorsements: 2

Use NewRow method of the datatable to get a blank datarow but with the schema as that of the datatable. You can populate this datarow and then add the row to the datatable using .Rows.Add(DataRow) OR .Rows.InsertAt(DataRow, Position).For more tips visit http://www.dapfor.com/en/net-suite/net-grid/features/performance

messyleon
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 0

thanks a lot! Problem solved!

Best Regards!

brylle
Junior Poster in Training
58 posts since Aug 2012
Reputation Points: -2
Solved Threads: 4
Skill Endorsements: 0
Question Answered as of 9 Months Ago by M.Waqas Aslam and messyleon

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0874 seconds using 2.72MB