Hi,
I have a dgv which I layout on a "form load" event and my code wasn't adding the row headers properly.
When I stepped through the code it got to the line where it added 8 rows (the dgv is not bound to a datasource) and then jumped out to another event (dgvHD_CD_CellEnter) and when that event finished, the code jumped back to the button on the previous form that had opened this form in the 1st place and missed out the rest of the code on the form load which set up the row headers.
After a lot of fannying about, I set the dgv.visible property to false before I added the rows and set it back again once I set up the row headers and this stopped the code jumping out of the "form load" code. I guess the dgvHD_CD_CellEnter event doesn't fire if the control isn't visible.
Is this behaviour normal?
My Code on the form load:
andCode:dgvHD_CD.Visible = False ' Now added to fix problem dgvHD_CD.Rows.Add(8) For byteRow_Index = 0 To 7 dgvHD_CD.Rows(byteRow_Index).HeaderCell.Value = strWell_Plates_Rows.ToString.Substring(byteRow_Index, 1) dgvHD_CD.Rows(byteRow_Index).Height = Math.Floor((dgvHD_CD.Height - dgvHD_CD.ColumnHeadersHeight) / 8) Next dgvHD_CD.SendToBack() dgvHD_CD.Visible = True
ThanksCode:Private Sub dgvHD_CD_CellEnter(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvHD_CD.CellEnter If boolLeft_Cell Then dt96_Description.Rows(byte96Cell_Row_Index).Item(byte96Cell_Column_Index) = txt96_Description.Text boolLeft_Cell = False End If txt96_Description.Text = "" If Len(dt96_Description.Rows(e.RowIndex).Item(e.ColumnIndex) & "") > 0 Then txt96_Description.Text = dt96_Description.Rows(e.RowIndex).Item(e.ColumnIndex) End If End Sub
Kristian




Reply With Quote
