davearia Posted June 26, 2005 Posted June 26, 2005 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 Quote
AlexCode Posted June 26, 2005 Posted June 26, 2005 Go here http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx and scroll down to answer: 5.35 How do I set the width of a column in my DataGrid? Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.