![](/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.