我在xtragrid单元格中有按钮。我想点击存储库按钮项时得到行索引。我怎样才能得到细胞信息或索引..
我想在另一个页面显示单元格信息,在行单元格中单击了存储库按钮..
你能帮帮我吗? 谢谢你的建议..答案 0 :(得分:2)
要获取有关Grid HitInfo的信息,请查看Hit Information Overview和Samples of Using Hit Information文档:
private void gridView1_MouseDown(object sender, MouseEventArgs e) {
// obtaining hit info
GridHitInfo hitInfo = gridView1.CalcHitInfo(new Point(e.X, e.Y));
if (((e.Button & MouseButtons.Right) != 0) && (hitInfo.InRow) &&
(!gridView1.IsGroupRow(hitInfo.RowHandle))) {
// switching focus
gridView1.FocusedRowHandle = hitInfo.RowHandle;
// showing the custom context menu
ViewMenu menu = new ViewMenu(gridView1);
DXMenuItem menuItem = new DXMenuItem("DeleteRow",
new EventHandler(DeleteFocusedRow));
menuItem.Tag = gridView1;
menu.Items.Add(menuItem);
menu.Show(hitInfo.HitPoint);
}
}
检查一下:
private void repositoryItemButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
myGridView.DeleteRow(myGridView.FocusedRowHandle); /// you can get focusedRowHandle here
}
参考:
Winforms XtraGrid Delete Row Button
Delete button on each row of grid - how do we prevent the user from typing text in the new column with the delete button
修改强> 参考这个Devexpres主题:Cannot get the rowhandle to delete a row using RepositoryItemButtonEdit