0

I haven't found exactly what i need in the forums. I don't want to move selection or scroll index, all what I need to is to change the entire row with a specific index to be the last line in my datagridview. I need this to happen automatically when i edit this row.

P.S. Datagrid is Unbound

for example:

dgv.rows(index).index=dgv.row.getlastrow

However, the debugger return an error that index is read only.

Please help guys!

charles
  • 55
  • 1
  • 10
  • 1
    Though your request seems kind of unusual to me, [check this post](https://social.msdn.microsoft.com/Forums/en-US/dd4e61e0-1dd0-4507-b2d7-e7a4e474c7de/move-updown-selected-rows-in-bound-datagridview-vbnet?forum=vbgeneral) or [this one](https://laxmanchip.wordpress.com/2010/12/02/move-an-unbound-datagridview-row-up-or-down-via-code-vb-net/) which might help you in your quest – boop_the_snoot Nov 01 '17 at 09:42
  • I haven't found a single thread about that, although it seems simple. isn't there a way to change the index of an unbound datagridview row? such as move next or more last – charles Nov 01 '17 at 09:47
  • oh sry i didnt see your links xDDDD – charles Nov 01 '17 at 09:51
  • I guess you saved my day mate thanks :) i will try the second one – charles Nov 01 '17 at 09:52
  • Don't play like that with a datagridview if you have a data source attached to it. You might cause something unwanted. If you are to do this then I would suggest you insert your rows on your own instead of relying on the functions with the datagridview that updates the grid for you. What you can Also do is to do a second datagridview right under the first one so when you edit a row, you are actually editing a row on a different datagrid but the user won't see that and if you have a lot of rows then you don't have to scroll down to view the last row, etc –  Nov 01 '17 at 12:22
  • no no, i already mentioned that the datagrid is unbound. i'm inserting rows to it manually. it has no datasource – charles Nov 01 '17 at 12:43

1 Answers1

0

This worked for me:

Dim curr_row As DataGridViewRow = idgv.Rows(Index)               
Dim curr_index As Integer=idgv.Rows.GetLastRow(DataGridViewElementStates.Visible)     
idgv.Rows.Remove(curr_row)
idgv.Rows.Insert(curr_index, curr_row)
boop_the_snoot
  • 3,209
  • 4
  • 33
  • 44
charles
  • 55
  • 1
  • 10