0

I use multiple xtragrids on a form and want to use a single context menu strip with a delete functions on these grids.I would like to handle the click event of the context menu:

private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GridView view = sender as GridView;
            {



            }
        }

tried this code,but for some reason i can not get the data from sender.Any chance of knowing which grid the menu was clicked on so i could delete the row from the clicked grid?

4

1 回答 1

1

您可以使用ContextMenuStrip.SourceControl来访问弹出的控件Context menu,当然当您右键单击您的网格时,SourceControl将是您的网格:

private void deleteToolStripMenuItem_Click(object sender, EventArgs e){
  GridView view = contextMenuStrip1.SourceControl as GridView;//Not sure if it's GridView or GridControl, you may want to try it yourself (I'm not familiar with DevExpress)
  //....
  //....
}
于 2013-09-12T01:37:42.210 回答