首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 中的 dateGridView 不能用右键取舍表记录

2012-09-27 
C# 中的 dateGridView 不能用右键选择表记录?只能用左键在grid 中选择记录,右键不能?有什么方法实现 左 右

C# 中的 dateGridView 不能用右键选择表记录?
只能用左键在 grid 中选择记录,右键不能?
有什么方法实现 左 右 键 都能选择?

[解决办法]
添加一个contextMenuStrip1 试试
[解决办法]

C# code
private void dgvList_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)        {            if (e.Button == MouseButtons.Right)            {                if (e.RowIndex >= 0)                {                    if (dgvList.Rows[e.RowIndex].Selected == false)                    {                        dgvList.ClearSelection();                        dgvList.Rows[e.RowIndex].Selected = true;                    }                    if (dgvList.SelectedRows.Count == 1 && e.ColumnIndex != -1)                    {                        dgvList.CurrentCell = dgvList.Rows[e.RowIndex].Cells[e.ColumnIndex];                    }                }            }        } 

热点排行