Ala*_*sen 19
使其行为与鼠标左键相似?例如
private void dataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
dataGridView.CurrentCell = dataGridView[e.ColumnIndex, e.RowIndex];
}
}
Run Code Online (Sandbox Code Playgroud)
小智 15
// Clear all the previously selected rows
foreach (DataGridViewRow row in yourDataGridView.Rows)
{
row.Selected = false;
}
// Get the selected Row
DataGridView.HitTestInfo info = yourDataGridView.HitTest( e.X, e.Y );
// Set as selected
yourDataGridView.Rows[info.RowIndex].Selected = true;
Run Code Online (Sandbox Code Playgroud)
很酷的是在右键单击上添加一个菜单,例如使用"查看客户端信息","验证最后发票","向此客户端添加日志条目"等选项.
您只需要添加一个ContextMenuStrip对象,添加您的菜单项,并在DataGridView属性中选择它的ContextMenuStrip.
这将在用户右键单击所有选项的行中创建一个新菜单,然后你需要做的就是让你的魔法:)
请记住,您需要JvR代码来获取用户所在的行,然后获取包含客户端ID的单元格并传递该信息.
希望它有助于改善您的申请
http://img135.imageshack.us/img135/5246/picture1ku5.png
http://img72.imageshack.us/img72/6038/picture2lb8.png
归档时间: |
|
查看次数: |
38395 次 |
最近记录: |