Hi all

I want to set my data grid column width separate for each column. Can it is possible?

I tried as follows...

gridMatchedDB.PreferredColumnWidth = 100

But its setting width to each column. How to set individually ???

try this:

gridMatchedDB.Columns(0).Width = 10 
gridMatchedDB.Columns(1).Width = 80

This should change the width of the first column to 10 en the second to 80

hi Nick
thanks for reply. i am using vb.net 1.0. And in this version the data grid has no column property...

Hi
Are you using DataTable to Display values in DataGrid?
If so try with the following DataGridTableStyle property

Dim l_dgtsl As DataGridTableStyle
        Try
            l_dgtsl = New DataGridTableStyle
            l_dgtsl.MappingName = DataTableName

            Dim l_dglnkCol As DataGridTextBoxColumn
            l_dglnkCol = New DataGridTextBoxColumn
            l_dglnkCol.MappingName = "Name" 'Column name in the data table
            l_dglnkCol.HeaderText = "Name" 'Display name in the grid header
            l_dglnkCol.Width = 60                   'Preferred width
            l_dgtsl.GridColumnStyles.Add(l_dglnkCol)

 DataGrid1.TableStyles.Clear()
            DataGrid1.TableStyles.Add(l_dgtsl)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.