ContextMenuStrip cms = new ContextMenuStrip();
ToolStripItem tsi = new ToolStripMenuItem("Мэдээлэл", null, (s, e) =>
{
if (DataModel != null)
{
GridItemMetaInfo f = new GridItemMetaInfo(DataModel);
f.Show();
}
});
cms.Items.Add(tsi);
GridItemContextMenu = cms;
/*GridView*/
private void Grd_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
showGridItemContextMenu((GridView)sender);
}
private void showGridItemContextMenu(GridView view)
{
if (view.FocusedColumn == null) return;
int ri = view.FocusedRowHandle;
int vi = view.FocusedColumn.VisibleIndex;
GridViewInfo info = (GridViewInfo)view.GetViewInfo();
GridCellInfo cell = info.GetGridCellInfo(ri, view.FocusedColumn);
System.Drawing.Rectangle r = cell.Bounds;
System.Drawing.Point point = new System.Drawing.Point(r.X + r.Width, r.Y + r.Height);
GridItemContextMenu.Show(view.GridControl, point);
}
private void showGridItemContextMenu(GridView view, System.Drawing.Point location)
{
GridHitInfo hitInfo = view.CalcHitInfo(location);
if (hitInfo.InRow)
{
view.FocusedRowHandle = hitInfo.RowHandle;
GridItemContextMenu.Show(view.GridControl, location);
}
}
No comments:
Post a Comment