Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All,

 

I am trying to customise my columns on a datagrid. I have used code similar to this before, however my code is not altering the column widths.

Here is the code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim mydgTableStyle As New DataGridTableStyle
       Dim mygrdColStyle1 As New DataGridTextBoxColumn
       Dim mygrdColStyle2 As New DataGridTextBoxColumn
       DataGrid1.TableStyles.Clear()
       With mydgTableStyle
           .MappingName = "ds.tables(0)"
       End With
       With mygrdColStyle1
           .HeaderText = "Email Address"
           .MappingName = "Email"
           .Width = 400
       End With
       With mygrdColStyle2
           .HeaderText = "Date Signed"
           .MappingName = "DateSigned"
           .Width = 60
       End With
       mydgTableStyle.GridColumnStyles.Add(mygrdColStyle1)
       mydgTableStyle.GridColumnStyles.Add(mygrdColStyle2)
       Try
           DataGrid1.TableStyles.Add(mydgTableStyle)
           DataGrid1.DataSource = ds.Tables(0)
       Catch ex As Exception
       End Try
End Sub

The datagrid populates from the dataset ds with no problems but the column names and column widths that I attempted to enforce have absolutely no effect.

 

Please help.

 

Thanks, Dave. :D :D :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...