我寫了一個事件來檢索點擊的單元格的第一個單元格值CellContentClick
事件datagridview
。但事件只會在單擊第三個單元格時得到提升,而當單擊datagridview的第一個或第二個單元格時不會引發該事件。
請幫幫我。Datagridview cellcontent click event not working properly
3
A
回答
7
嘗試實施CellClick
事件,而不是CellContentClick
事件
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView theGrid = sender as DataGridView;
if(theGrid != null)
{
DataGridViewCell selectedCell = theGrid.SelectedCells[0];
//Do your logic here
}
}
1
的要添加到拉米的回答,您還需要更新默認生成的代碼窗體的Designer.cs
。
原始代碼:
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
將其更改爲:
this.dataGridView1.*CellClick* += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
相關問題
- 1. textbox keyup event not working properly
- 2. ng-click event not working
- 3. Jquery table td click click not working properly
- 4. jquery click event not working with children
- 5. Sortable not working properly
- 6. PHP:Header not working properly
- 7. CSS:float:right not working properly
- 8. display:none not working properly
- 9. this.Cursor not working properly?
- 10. Listview not working properly
- 11. AlarmManager.SetRepeating not working properly
- 12. class not working properly
- 13. chrome.storage.local.set/get not working properly?
- 14. text_changed event not working
- 15. Select Statement not working properly
- 16. Junit @Before not working properly
- 17. UIViewController shouldAutorotateToInterfaceOrientation not working properly
- 18. Luhn's Algorithm not working properly
- 19. Laravel groupBy not working properly
- 20. Angular click event not working,what給出?
- 21. select event not working
- 22. If-else if statement not working properly
- 23. 排序By Row_number not working properly
- 24. C++ if if else not working properly
- 25. Flot with JSON not working properly
- 26. onbeforeunload onunload performance.navigation.type not working properly
- 27. UiApplication.getUiApplication()。popScreen(ScreeName.this)not working properly
- 28. objective-c:if statement not working properly
- 29. Karma - base path not working properly
- 30. while while while not working properly
粘貼一些相關的代碼,請 – Waqas