I have a problem I was hoping someone could assist me in solving.
Situation: I am using a datagrid with code generated style.
Problem: During form load event the PreferredRowHeight is not being adjust to what I have set it to in the code. All other settings for the datagrid are being displayed correctly. Only the PreferredRowHeight is not loading the code generated settings.
Furthermore: I have a button that clears the datagrid. I basically create a dataset that has nothing in it, and bind it to the datagrid. After I clear the datagrid, and load new information in it, the PreferredRowHeight works properly, it just does not work during the first form load event.
Code:
'Datagrid2 settings
If Not Datagrid2.TableStyles.Contains("DataInfo") Then
'create datagrid2 table style
Dim tblStyle As New DataGridTableStyle
'properties
tblStyle.MappingName = dt.TableName
Datagrid2.TableStyles.Add(tblStyle)
tblStyle.RowHeadersVisible = False
tblStyle.HeaderBackColor = Color.Red
tblStyle.AllowSorting = False
tblStyle.HeaderForeColor = Color.White
tblStyle.GridLineColor = Color.Red
tblStyle.BackColor = Color.White
tblStyle.PreferredRowHeight = 22
'create Datagrid2 column style
Dim colStyle As GridColumnStylesCollection
colStyle = Datagrid2.TableStyles(0).GridColumnStyles
colStyle(0).Width = 100
colStyle(1).Width = 178
colStyle(2).Width = 150
colStyle(3).Width = 150
End If
Situation: I am using a datagrid with code generated style.
Problem: During form load event the PreferredRowHeight is not being adjust to what I have set it to in the code. All other settings for the datagrid are being displayed correctly. Only the PreferredRowHeight is not loading the code generated settings.
Furthermore: I have a button that clears the datagrid. I basically create a dataset that has nothing in it, and bind it to the datagrid. After I clear the datagrid, and load new information in it, the PreferredRowHeight works properly, it just does not work during the first form load event.
Code:
'Datagrid2 settings
If Not Datagrid2.TableStyles.Contains("DataInfo") Then
'create datagrid2 table style
Dim tblStyle As New DataGridTableStyle
'properties
tblStyle.MappingName = dt.TableName
Datagrid2.TableStyles.Add(tblStyle)
tblStyle.RowHeadersVisible = False
tblStyle.HeaderBackColor = Color.Red
tblStyle.AllowSorting = False
tblStyle.HeaderForeColor = Color.White
tblStyle.GridLineColor = Color.Red
tblStyle.BackColor = Color.White
tblStyle.PreferredRowHeight = 22
'create Datagrid2 column style
Dim colStyle As GridColumnStylesCollection
colStyle = Datagrid2.TableStyles(0).GridColumnStyles
colStyle(0).Width = 100
colStyle(1).Width = 178
colStyle(2).Width = 150
colStyle(3).Width = 150
End If