0

I have devexpress gridcontrol which looks like that: enter image description here

I have click event on this red X button:

private void delete_button_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{

}

How can get there row index where this button is ?

godot
  • 3,422
  • 6
  • 25
  • 42

2 Answers2

2

You cannot access rows on GridControl, since this is just a container for the views. As I can see from your picture you're using GridView. When you press the delete button, focused row changes and you can access it via FocusedRowHandle.

private void delete_button_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
  var gv = myGridControl.MainView as GridView;
  var index = gv.FocusedRowHandle;

  gv.DeleteRow(index);
}
Marko Juvančič
  • 5,792
  • 1
  • 25
  • 41
1

You can use the GridView.FocusedRowHandle property:

 view.DeleteRow(view.FocusedRowHandle);
Dmitrii Babich
  • 489
  • 3
  • 4