Please guide me how to prevent new rows added automatically on DevExpress.XtraGrid.GridControl
I want to control when new rows is added, in my case i'm using a keydown event (CTRL + I ) for this task. But the grid keep adding new rows automatically if i move the focus (cursor pointer) to the area right below to the last row and click.
The GridControl.MainView is a BandedGridView, which contains the datasource.
You can use
BandedGridView.OptionsView.NewItemRowPosition
property. You can set its value toNewItemRowPosition.None
to hide new item row.Another way is to handle
BandedGridView.ShownEditor
event. Inside of this you can check ifBandedGridView.FocusedRowHandle
property is equals toGridControl.NewItemRowHandle
and cancel editor activation.Here is example:
You can handle the ValidateRow event. If you set
e.Valid = false
you wont add a new row. So check if your object is empty or invalid and just if the needed values are typed you give the row free.As of version 15 you can simply set your TableView's NewItemRowPosition to NewItemRowPosition.None. Be sure to call CommitEditing() on your TableView first.