【问题标题】:.Net How Select a Particular Row In dataGridView when User Right Clicks.Net如何在用户右键单击时选择dataGridView中的特定行
【发布时间】:2011-12-15 14:28:24
【问题描述】:

我有一个 datagridview 控件,我想在用户右键单击特定行时执行一些操作,但是 datagridview 只能在右键单击之前先左键单击该行时选择该行。

【问题讨论】:

    标签: .net datagridview


    【解决方案1】:

    尝试订阅 CellMouseDown 事件:

    private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) {
      if (e.Button == MouseButtons.Right && e.RowIndex >=0)
        dataGridView1.Rows[e.RowIndex].Selected = true;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-05-21
      • 1970-01-01
      • 2021-08-19
      • 2022-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-02
      相关资源
      最近更新 更多