|
-
Sep 8th, 2007, 08:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Iserting new row into Datagridview
Hello everybody,
I have unbounded datagridview, and I am using the next command to add new row:
Code:
tblResults.Rows.Add()
This command adds new row at the bottom of the datagridview.
I need a method to insert a row in the middle of the datagridview, before or after selected row or at the specified position.
I would appreciate your advice.
-
Sep 8th, 2007, 09:21 AM
#2
Re: Iserting new row into Datagridview
The DataRowCollection class, just like any collection type class, has the member "InsertAt" where you can specify an index to insert to. So all you need to do is to use the right method
Code:
tblResults.Rows.InsertAt(theNewDataRow, index)
-
Sep 8th, 2007, 04:36 PM
#3
Thread Starter
Addicted Member
Re: Iserting new row into Datagridview
Thanks Stanav.
One more question,
how can I know wich row is currently selected?
-
Sep 8th, 2007, 04:51 PM
#4
Re: Iserting new row into Datagridview
DataGridView.CurrentRow gives you the current row of your DGV. From there, you can read the RowIndex property.
-
Sep 8th, 2007, 05:17 PM
#5
Thread Starter
Addicted Member
Re: Iserting new row into Datagridview
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|