Grid column-styles widths not applied (see style code)

  • Thread starter Thread starter peteg1
  • Start date Start date
P

peteg1

Guest
I have a not-strongly-typed VB.NET 2003 dataset and one table displayed in a datagrid using a dataview. The display is entirely proper prior to applying a style. Applying a style (code below) results in very small column widths, with everything scrunched to the left. Expanding the columns using the cursor shows that all other style directives have been applied; just column widths have not been applied. Here’s the style code:



Private Sub gridstyle()

Set the styles of the columns of the grid.

Dim dgY1 As New DataGridTableStyle



dgY1.GridLineColor = System.Drawing.Color.Green

dgY1.HeaderForeColor = System.Drawing.SystemColors.ControlText

dgY1.MappingName = "tblport"

dgY1.PreferredColumnWidth = 15

dgY1.RowHeaderWidth = 30



Dim ycol As New DataGridTextBoxColumn

ycol.Format = ""

ycol.HeaderText = "symbol" ‘ String

ycol.MappingName = "symbol"

ycol.Width = 7

dgY1.GridColumnStyles.Add(ycol)



ycol = New DataGridTextBoxColumn

ycol.Format = ""

ycol.HeaderText = "secType" ‘ String

ycol.MappingName = "secType"

ycol.Width = 4

dgY1.GridColumnStyles.Add(ycol)



ycol = New DataGridTextBoxColumn

ycol.Alignment = System.Windows.Forms.HorizontalAlignment.Right

ycol.Format = "00.0"

ycol.HeaderText = "strike" ‘ Int32

ycol.MappingName = "strike"

ycol.Width = 7

dgY1.GridColumnStyles.Add(ycol)



ymarketPrice



ycol = New DataGridTextBoxColumn

ycol.Alignment = System.Windows.Forms.HorizontalAlignment.Right

ycol.Format = "00.00"

ycol.HeaderText = "marketPrice" ‘ Double

ycol.MappingName = ""

ycol.Width = 7

dgY1.GridColumnStyles.Add(ycol)



DataGrid1.TableStyles.Add(dgY1)



End Sub



What is missing from my code to make the columns display properly wide?









Continue reading...
 


Write your reply...
Back
Top