[英]How to get the index of the selected column in data grid view in windows forms using c#?
如何獲取DataGridView中選定列的索引? (使用C#的Windows窗體)
我有一個包含30列的DataGridView。現在的任務是,當用戶單擊30列標題中的任何一個時,所選的列索引將顯示在消息框中。我需要幫助。
在ColumnHeaderMouseClick中編寫代碼
private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
MessageBox.Show(e.ColumnIndex.ToString());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.