I'm not able to figure out why this will not insert a value into the datagridview cell:
I don't get an error and the cells are just blank. When I set a break during debug on the rows.Cells("StartDate").Value = "SomeValue" I can see that the line recognizes the value "SomeValue" for that line.
Stumped.
UPDATE:
Okay, after a day of messing with this on and off I've found that adding this exact same code to a button click event makes it work. But calling this code in a stand alone Sub it doesn't work. Can anyone tell me why?
VB.NET:
Dim SDateCol As New DataGridViewTextBoxColumn
SDateCol.HeaderText = "StartDate"
SDateCol.Name = "StartDate"
DataGridView5.Columns.Insert(4, SDateCol)
Dim cS As DataGridViewColumn = Me.DataGridView5.Columns("StartDate")
cS.Width = 65
For Each row As DataGridViewRow In DataGridView5.Rows
row.Cells("StartDate").Value = "SomeValue"
Next
I don't get an error and the cells are just blank. When I set a break during debug on the rows.Cells("StartDate").Value = "SomeValue" I can see that the line recognizes the value "SomeValue" for that line.
Stumped.
UPDATE:
Okay, after a day of messing with this on and off I've found that adding this exact same code to a button click event makes it work. But calling this code in a stand alone Sub it doesn't work. Can anyone tell me why?
Last edited: