Home Forums WinForms controls Xceed Grid for WinForms getfittedwidth-method for unbound detailgrids Reply To: getfittedwidth-method for unbound detailgrids

User (Old forums)
Member
Post count: 23064

I’ve got the same problem, see code below…

Dim ds As System.Data.DataSet = pageView.Runtime.DataSet
Dim table As String = pageView.Table.Name
Dim strTemp As String = “”
Dim intTemp As Integer
Dim details As DetailGrid

objForm.XceedGridControl.BeginInit()

objForm.XceedGridControl.SetDataBinding(ds, table)

‘ Bind any pageview children
If pageView.Child IsNot Nothing Then
‘ Add the child pageviews
details = New DetailGrid
details.SetDataBinding(pageView.Child.Runtime.DataSet, pageView.Child.Table.Name)
details.HeaderRows.Add(New ColumnManagerRow())
objForm.XceedGridControl.DetailGridTemplates.Add(details)
End If

objForm.XceedGridControl.EndInit()

If pageView.Child IsNot Nothing Then
For Each df As DisplayField In pageView.Child.Fields
‘ Styling
intTemp = objForm.XceedGridControl.DetailGridTemplates.Item(0).Columns.df.DataField).GetFittedWidth
objForm.XceedGridControl.DetailGridTemplates.Item(0).Columns(df.DataField).ReportStyle.Width = CInt(intTemp + (intTemp / 10))

Next
End If

objForm.XceedGridControl.UpdateDetailGrids()

The columns seem to size only by the columns headerrow rather than the contents of the each of the cells in the columns. Any ideas?

Imported from legacy forums. Posted by Mark (had 465 views)