![](/img/trans.png)
[英]What event and code in visual basic when the header in datagridview is clicked then all cell in that column will highlighted?
[英]How to check the header text of a DataGridView column of a selected cell in Visual Basic
我在Visual Basic中有一个datagridview。 我想调整一个子控件来完成以下任务:当用户在DGV(单元格单击事件)中选择一个单元格时,我想检查列标题文本。 在我的示例中,如果该列的标题文本为“ MinEquation”,那么我想执行一些事件。 我不能使用列索引的原因是,我在具有不同数据表的循环中动态创建了这些DGV。 如何对所选单元格的列标题文本进行比较运算符。 谢谢!
您将生成DataGridView的CellClick事件 ,然后使用DataGridViewCellEventArgs返回该列的信息。 看一下这个例子:
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
If DataGridView1.Columns(e.ColumnIndex).HeaderText = "MinEquation" Then
'Match
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.