2017-02-24 67 views
0

我在學習Windows Visual C#所以我對此很陌生。我對細胞點擊事件此代碼爲我的DataGridViewDatagridView單元格在可視c中點擊事件#

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) 
    { 
     con. ID = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()); 
     txtname.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); 
     txtlname.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); 
    } 

的問題是:我甚至有多少次點擊我的DataGridView這不是我的射擊斷點。如何解決這個問題?

+0

你確定你是在網格中點擊你的細胞?因爲你的代碼看起來很好。 –

+0

您是否添加了事件處理程序? https://msdn.microsoft.com/en-us/library/dd553231.aspx它可能會更容易在VB.Net中嘗試它,直到你習慣了事件處理程序 – Slai

+0

@MAdeelKhalid是的我相信。在我點擊我的DataGridView之後,我希望數據在文本框中顯示。 – KiRa

回答

1

這樣,

可以達到通過右擊或選擇datagridview後,按F4性能。

enter image description here

按閃電圖標,雙擊你要處理的事件之後。

enter image description here

最後你會看到這一點,

enter image description here

希望幫助,

相關問題