How should I delete all rows from the grid?
Private Sub ClearFilterGrid() grdFilter.Selected.Rows.AddRange(CType(grdFilter.Rows.All, UltraGridRow())) ' Can't select more than 1 row when SelectType is Single or SingleAutoDrag grdFilter.DeleteSelectedRows() End Sub
Now, is there an other method but selecting the rows?Say, if I have a special behavior when a row is selected, I don't want to raise some unuseful events, I just want to delete rows in the grid, it-s all.
I want to allow the user delete all rows, but the last one.
Tring your method your method I finally obtained a stange unhandleld exception, without any stacktrace:
Internal error: can't convert to DestinationValue.
Infragistics v6
I tried one more time... it worked that time )
I'm not entirely sure what you mean.
If you don't want to allow the user to delete rows, why are you cancelling the event ?Instead, set the property AllowDelete to false:UltraGrid1.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False
Anyway, if you still want to keep the event, you could try this:
RemoveHandler UltraGrid1.BeforeRowsDeleted, AddressOf UltraGrid1_BeforeRowsDeleted UltraGrid1.Rows.Last().Delete() AddHandler UltraGrid1.BeforeRowsDeleted, AddressOf UltraGrid1_BeforeRowsDeleted
Make sure you have any rows to delete first, or you could get an exception.
Thank you, it worked... partially....
Previously I denied the last row deletion (by user only)
Private Sub grdFilter_BeforeRowsDeleted(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs) Handles grdFilter.BeforeRowsDeleted If grdFilter.RowCount = e.Rows.Count Then e.Cancel = True End Sub
So that did from the above delete code a infinite loop...
Now, I would like to be able to remove that last row by code, but do not allow user to remove it...
Hey,
This seems to work for me:
While UltraGrid1.Rows.Count > 0 UltraGrid1.Rows(0).Delete(False) End While
Kind regards,
Michael
I am afraid I have no DataSource on the grid, because I fill-in manually.