DataGrid Columns

  • Thread starter Thread starter CSL
  • Start date Start date
C

CSL

I am using the DataGrid in a Windows Application, how can
I adjust the widths of each column individually.
 
Hi,

You have to add a tablestyle to your grid. When filling for your
dataset specify a tablename that will be your mappingname. ie
DataAdapter.Fill(dataset, "MappingName")
Private Sub SetupGrid()

Dim ts As New DataGridTableStyle

ts.MappingName = "InvoiceData"

Dim colDescription As New DataGridTextBoxColumn

With colDescription

..MappingName = "Description"

..HeaderText = "Description"

..Width = 280

..NullText = ""

End With

Dim colQty As New DataGridTextBoxColumn

With colQty

..MappingName = "Quantity"

..HeaderText = "Qty"

..Width = 50

End With

Dim cm As CurrencyManager = CType(Me.BindingContext(dvClient),
CurrencyManager)

Dim pd As System.ComponentModel.PropertyDescriptor =
cm.GetItemProperties()("Each")



Dim colEach As New DataGridTextBoxColumn(pd, "C")

With colEach

..MappingName = "Each"

..HeaderText = "Each"

..Width = 50

End With

Dim colPrice As New DataGridTextBoxColumn(pd, "C")

With colPrice

..MappingName = "Price"

..HeaderText = "Price"

..Width = 50

End With

ts.GridColumnStyles.Add(colDescription)

ts.GridColumnStyles.Add(colQty)

ts.GridColumnStyles.Add(colEach)

ts.GridColumnStyles.Add(colPrice)

dgInvoiceData.TableStyles.Add(ts)

ts = Nothing

colPrice = Nothing

colEach = Nothing

colQty = Nothing

colDescription = Nothing

End Sub

Ken
 
Joe,

Lot here to try and work on thank you I will let you know how it goes......
 
Back
Top