C# Data Grid Issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am dealing with this problem for some time now, i want to find out if there is a way to change the Column widths of DataGrid based on the the maximum size of the cell (content) for that column, or for that matter, if there is a way to programatically change the column width of Data grid populated from a select query.

With Regards
Sunny
 
Here's a quick sample of how it works... you'll need to use the TableStyles
and ColulmnStyles....
Dim csDeleteCode As New DataGridTextBoxColumn

With csDeleteCode

..MappingName = AllData.Tbl_Job_Tracking.Columns(12).ColumnName

..HeaderText = "Delete Code"

..Width = 70

..NullText = ng

End With

tsMain.GridColumnStyles.Add(csDeleteCode)

dg.TableStyles.Add(tsMain)

dg.ResumeLayout()

Catch ex As Exception

Debug.Assert(False, ex.ToString)

End Try

Sunny said:
I am dealing with this problem for some time now, i want to find out if
there is a way to change the Column widths of DataGrid based on the the
maximum size of the cell (content) for that column, or for that matter, if
there is a way to programatically change the column width of Data grid
populated from a select query.
 
Back
Top