读书人

gridview 右键出菜单 不知有没有更好的

发布时间: 2012-01-16 23:36:51 作者: rapoo

gridview 右键出菜单 不知有没有更好的方法
分少
但是是全部了
今天结
我想要的是不用自己设变量
不知道怎么取 在contextMenuStrip1_Click里
以下是我的
#region dataGridView2_CellMouseDown
private void dataGridView2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
strdgv2 = this.dataGridView2[0, e.RowIndex].Value.ToString();
dataGridView2.ContextMenuStrip = contextMenuStrip1;


}
}
#endregion

#region contextMenuStrip1_Click
private void contextMenuStrip1_Click(object sender, EventArgs e)
{

string myStr = e.GetHashCode().ToString();
SetDatagridview1(strdgv2);//显示对应信息
}
#endregion

[解决办法]
没有了,微软MSDN上提供的例子都是使用的这种方法,应该没有更好的了

读书人网 >C#

热点推荐