In DataGridView, how can i input data then add row

Recommended Answers

All 3 Replies

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

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

thanks a lot! Problem solved!

Best Regards!

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.