To reproduce:
- use the code below to create an application
- start it and click the Id column twice (so you will sort it first ascending and then descending)
- double click the first row (with ID=9) => the BindingList current is still the row with ID 0, while it should be the row with ID 9
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SetDefaults();
}
private void SetDefaults()
{
radGridView1.MasterTemplate.AutoGenerateColumns = false;
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
radGridView1.MasterTemplate.EnableAlternatingRowColor = true;
radGridView1.TableElement.AlternatingRowColor = Color.FromArgb(0xEB, 0xEF, 0xFB);
radGridView1.MasterTemplate.ShowGroupedColumns = true;
radGridView1.MasterTemplate.EnableGrouping = true;
radGridView1.MasterTemplate.MultiSelect = false;
radGridView1.EnableFiltering = true;
radGridView1.EnableFastScrolling = true;
radGridView1.TableElement.TableHeaderHeight = 50;
}
private void Form1_Load(object sender, EventArgs e)
{
var users = new EmployeeList();
for (int i = 0; i < 10; i++)
{
var user = new Employee();
user.Id = i;
user.Name = "John Doe " + i;
users.Add(user);
}
employeeListBindingSource.DataSource = users;
}
private void radGridView1_CellDoubleClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
if (e.RowIndex == -1 || e.Row.RowElementType != typeof(GridDataRowElement) || !(e.Row is GridViewDataRowInfo))
return;
var selectedUser = employeeListBindingSource.Current as Employee;
MessageBox.Show(selectedUser.Name);
}
}
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public Employee()
{
}
}
public class EmployeeList : BindingList<Employee>
{
public EmployeeList()
{
}
}