README.md

December 4, 2022 ยท View on GitHub

Set Datagrid Column Width

Description

This is a simple example of how to dynamically set the column width in a DataGrid control. I spent hours trying to find something that seemed to me should have been a simple help example. I hope I can save somebody some time.

More Info

Submitted On
ByMike M. Mitchell
LevelBeginner
User Rating4.1 (58 globes from 14 users)
CompatibilityVB.NET
CategoryAlgorithims
World.Net (C#, VB.net)
Archive File

Source Code

Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle()
    'Map the style to the dataset table. In this case I only use one table
    ' in my query.
    myGridTableStyle.MappingName = "Insured"
    grdQuotes.TableStyles.Add(myGridTableStyle)
    myGridTableStyle.GridColumnStyles(0).Width = 0
    myGridTableStyle.GridColumnStyles(1).Width = 250
    myGridTableStyle.GridColumnStyles(2).Width = 250