Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

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

$
0
0

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:

 

PrivateSub gridstyle()

        ' Set the styles of the columns of the grid.

        Dim dgY1 AsNew DataGridTableStyle

       

        dgY1.GridLineColor = System.Drawing.Color.Green

        dgY1.HeaderForeColor = System.Drawing.SystemColors.ControlText

        dgY1.MappingName = "tblport"

        dgY1.PreferredColumnWidth = 15

        dgY1.RowHeaderWidth = 30

        '

        Dim ycol AsNew 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)

 

    EndSub

 

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

 

 

 

 

 


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>