可视c ++ dataGridView cellclick事件

时间:2018-08-19 11:09:30

标签: visual-studio visual-c++ datagridview c++-cli clr

我用cellclick搜索了dataGridView中的c++事件。所有结果均与c#有关。
我的dataGridView1选择模式是FullRowSelect。我的目标是当我单击任何单元格(行)时,检测到该行并执行某项操作。

int i;
private: System::Void dataGridView1_CellDoubleClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e)
{
   if (double clicked row 1)
   { 
      int = 1;
   }
   if (double clicked row 2)
   {
      int = 2;
   }
}

我需要任何简单的例子或任何学习的资源。谢谢。

1 个答案:

答案 0 :(得分:0)

ok在c#教程中找到了解决方案,并转换为c ++-clr

    if (e->RowIndex == 1) //that's what i looking for, you can use ColumnIndex too.
{
    int = 1;
}

非常适合c ++-clr。

msdn上的

DataGridViewCell.RowIndex属性也有帮助。

相关问题