Hi,
Version: 2017.3.1017.20
Code to reproduce problem below. Just create new form and copy-paste code below.
public
partial
class
Form : System.Windows.Forms.Form
{
public
Form()
{
InitializeComponent();
}
private
void
Form_Load(
object
sender, EventArgs e)
{
RadGridView grid =
new
RadGridView();
grid.Dock = DockStyle.Left;
grid.SortDescriptors.Add(
"Id"
, ListSortDirection.Ascending);
grid.SelectionMode = GridViewSelectionMode.FullRowSelect;
BindingList <X> bindingList =
new
BindingList<X>();
bindingList.Add(
new
X() { Id = 1, Name =
"Row 1"
});
bindingList.Add(
new
X() { Id = 5, Name =
"Row 5"
});
bindingList.Add(
new
X() { Id = 3, Name =
"Row 3"
});
bindingList.Add(
new
X() { Id = 4, Name =
"Row 4"
});
bindingList.Add(
new
X() { Id = 2, Name =
"Row 2"
});
bindingList.Add(
new
X() { Id = 6, Name =
"Row 6"
});
bindingList.Add(
new
X() { Id = 7, Name =
"Row 7"
});
bindingList.Add(
new
X() { Id = 8, Name =
"Row 8"
});
bindingList.Add(
new
X() { Id = 9, Name =
"Row 9"
});
bindingList.Add(
new
X() { Id = 10, Name =
"Row 10"
});
Controls.Add(grid);
grid.DataSource = bindingList;
RadButton radButton =
new
RadButton();
radButton.Text =
"Delete row"
;
radButton.Dock = DockStyle.Right;
radButton.Click +=
delegate
{
var selected = (X)grid.CurrentRow.DataBoundItem;
bindingList.Remove(selected);
};
Controls.Add(radButton);
}
}
public
class
X
{
public
Int32 Id {
get
;
set
; }
public
String Name {
get
;
set
; }
}
My grid is connected to binding list. Clicking on the button remove currently selected row from binding list.
The problem is: Sometimes after deleting, nearest row is selected. Sometimes grid is clearing selection.
Please see attached gif.
I would like the next record to be always selected after deleting current one.
If deleted row was last row, it should select previous one.
I was trying to use GridNavigator.SelectPreviousRow(1) and GridNavigator.SelectNextRow(1) but it do not work, becouse sometimes after deleting row grid is clearing selection.