【问题标题】:Relative click location in a DataGridView CellDataGridView 单元格中的相对单击位置
【发布时间】:2019-01-08 00:34:37
【问题描述】:

我一直在寻找解决问题的方法。
我正在尝试检测一次点击,当此点击是在我的单元格的最后一个 20px 中执行时,相对位置(从左侧开始)。

我回顾了一些类似的情况但没有成功,因为它们检测到点击单元格的左上角x, y点。

【问题讨论】:

    标签: c# .net winforms datagridview


    【解决方案1】:

    您可以在CellMouseDown 事件中拦截鼠标单击位置。这将为您提供当前单元格内指针的相对位置:

    private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
    {
        if (e.X > (sender as DataGridView)[e.ColumnIndex, e.RowIndex].Size.Width - 20)
            MessageBox.Show("Clicked right there!");
    }
    

    【讨论】:

      猜你喜欢
      • 2011-08-21
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 2021-05-03
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      相关资源
      最近更新 更多