当用户从弹出菜单中选择一个选项时,我试图从网格中获取选定的行。我有以下代码
private void gridView1_PopupMenuShowing(object sender,
DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
{
if (e.MenuType != DevExpress.XtraGrid.Views.Grid.GridMenuType.Row) return;
var item = new DXMenuItem("Delete");
item.Click += (o, args) =>
{
var rowHandles = gridView1.GetSelectedRows();
foreach (var rowHandle in rowHandles)
{
System.Data.DataRow row = gridView1.GetDataRow(rowHandle);
// debugger shows that rowHandle = 1
if (row == null)
{
Console.WriteLine("how so?"); // breaks here
}
}
};
e.Menu.Items.Add(item);
}
当我在调试器中运行时,我希望该行有效,但它为空。