DevExpress中GridView上的右键菜单
如上图,先选中GridView,不是GridControl,在属性窗口中,选择事件窗口,注册事件MouseUp
代码如下,其中popupMenu_ResumeGrid为DevExpress.XtraBars.PopupMenu
gridView_ResumeCollection为private DevExpress.XtraGrid.Views.Grid.GridView
----------------------------------------------------------------
private void gridView_ResumeCollection_MouseUp(object sender, MouseEventArgs e) {
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi =this.gridView_ResumeCollection.CalcHitInfo(e.Location);
if (hi.InRow && e.Button == MouseButtons.Right) {
popupMenu_ResumeGrid.ShowPopup(Control.MousePosition);
}
}
----------------------------------------------------------------
备注序列化和反序列化代码
IFormatter formatter = new BinaryFormatter();
using (Stream stream = new FileStream(ResumeCollection.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read)) {
if (stream.Length > 0) {
formatter.Serialize(stream, new object());
//ResumeCollection = (ResumeCollection)formatter.Deserialize(stream);
stream.Close();
}
}