0

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 ???

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by suganzeni
0

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

Edited by Nick Evan: n/a

0

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

Edited by Nick Evan: n/a

0

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

Edited by Nick Evan: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.