![](/img/trans.png)
[英]How can I detect the cell value changed of a specific datagridview column? - VB.NET
[英]How do I get a value from a specific column in a vb.net datagridview?
我創建了一個數據表作為我的datagridview的源,如下所示:
Dim dt As New DataTable
dt.Clear()
DataGridView1.DataSource = dt
dt.Columns.Add("Customer")
dt.Columns.Add("Dtime")
dt.Columns.Add("Title")
dt.Columns.Add("EventID")
EventID是數字,將被傳遞到新表單以告訴它要打開哪條記錄(該位有效,我可以在另一表單上使用它)。
我努力了:
event = DataGridView1.SelectedRows(e.RowIndex).Cells(3).Value.ToString
event = Convert.ToInt32(DataGridView1.SelectedRows(0).Cells(3).Value.ToString)
event = Convert.ToInt32(DataGridView1.Item("EventID", DataGridView1.CurrentRow.Index).Value.ToString)
以及我在本網站和其他網站上可能找到的其他十二種方法,但我不斷遇到相同的錯誤:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
它讓我發瘋,我在做什么錯? 請幫忙!
event = DataGridView1.Rows(e.RowIndex).Cells(3).Value.ToString()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.