Eric
  • Eric
  • Member Topic Starter
2016-08-11T02:10:10Z
Hi I am Using the iGrid.Rows.RemoveAt(RowIndex) Method to Remove A Selected Row In the Igrid. The User Selects a Row (iGrid Is in RowMode=true), Using the SelectionChanged Event I pop Up A dialogue and and Depending on the result of that dialogue I either cancel or run The PerformAction.Deselectallrows action, then run the removeAt method. Works fine unless I am removing the Last row in the grid. I get a 'Specified argument was out of the range of valid values" Exception. Anyone Experience problem with removing the last row of iGrid? Thanks -Eric
Igor/10Tec
2016-08-17T08:25:13Z
Your task is clear, but the implementation logic looks complicated. Why do you deselect all rows before removing the selected row? Does you grid work in multi-select mode?

To investigate the issue, prepare and send us a simple project we can launch on our pc to reproduce the error.

One more tip: I would not deselect and/or remove the selected row in the SelectionChanged event as theoretically it may conflict with the internal logic related to finishing the operation of selection change (updating internal vars and collections, etc.) Instead, you can start a timer and remove the row in the timer's event. The idea of this approach is that the removal work is done completely outside of the SelectionChanged event.
Igor/10Tec
2016-08-18T09:50:51Z
I reproduced the problem myself. Indeed, the exception occurs because iGrid tries to set the selection and the new current row when you click a row in the grid (in this order). If you remove the clicked row in the SelectionChanged event before iGrid changes the current row, the new current row will be the next row after the row you remove. And sure, the exception occurs as there is no next row after the last one.
Igor/10Tec
2016-08-18T10:17:03Z
One more comment regarding your logic. The SelectionChanged event is also raised when the user changes the current cell or row using the keyboard. What if the user just wants to move the selection to the next row? In your grid rows will be removed when the user presses UP ARROW or DOWN ARROW every time...

My recommendation: move your logic to a mouse event. For instance, CellMouseUp. I have just tried it. It works as expected without exceptions.
Eric
  • Eric
  • Member Topic Starter
2016-08-31T02:31:59Z
Hi, Thank you for getting back to me, and sorry that I have not responded until now. I changed My Event To The CurRowChange Event and have had no problems doing it there (My igrid is in rowmode, and selectionmode is one). The background for this app is that users are scanning barcoded items and they populate in the igrid as they are scanned. If there is any issue with the item they have scanned, the backcolor turns either red or orange depending on our rules. Also, We Are Using All in One Touch Screens For this App, so when the users selects one of the red or orange rows, a dialogue form displays and the user selects an option (one of them being to remove the item from the list). After the dialogue option is selected, the igrid deselects all of its rows (this is because i never want to keep an item in the igrid selected because of the backcolors which display the item's status). If the user selection was to remove the item, then I use the removeat method and run some other refresh subs on my form. Anyways, all is working well and I wanted to say great work to you all of the developers on igrid, it truly is the 'Do Anything' Solution for all of our data needs and I am in the process of converting all of my old listviews and datagridviews to igrid. Thanks!