from
http://www.thecodeproject.
only 2 props not work in cf are
DGStyle.AllowSorting = False
DGStyle.AlternatingBackCol
Main Topics
Browse All TopicsHi, I'm developing an mobile application for a Pocket PC. I'm using VB.Net compact framework in a Visual Studio .Net 2003 Environment.
Does anyone know how I can make my datagrid expand the column headers to fit the header text in? At the moment the header text is cut off, as all the columns seem to be the same fixed size. If possible, can it be done through Visual Studio .Net (properties box) as opposed to through coding? Although if there's a coded solution that's fine too.
Thanks guys... this on'e had me beat for about a month now.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
from
http://www.thecodeproject.
only 2 props not work in cf are
DGStyle.AllowSorting = False
DGStyle.AlternatingBackCol
Business Accounts
Answer for Membership
by: ScoobyedPosted on 2004-07-23 at 07:13:30ID: 11621518
Public Sub formatDGHead(ByVal dg As DataGrid)
or = Color.Gainsboro al))) dd(textCol umn) )
' Assume DataGrid DataSource is a DataSet
If dg.DataSource.GetType() Is Me.DataSet11.GetType Then
Dim ds As DataSet
ds = CType(dg.DataSource, DataSet)
If Not (ds Is Nothing) Then
' contains at least one table.
If dg.TableStyles.Count > 0 Then
dg.TableStyles.Clear()
End If
Dim sumWidths As Single = 0.0F
Dim dt As DataTable
For Each dt In ds.Tables
' DataTable dt = ds.Tables[tableName];
Dim DGStyle As New DataGridTableStyle
DGStyle.MappingName = dt.TableName
DGStyle.AllowSorting = False
DGStyle.AlternatingBackCol
Dim textColumn As DataGridTextBoxColumn
Dim cWidths As New ArrayList
Dim g As Graphics = dg.CreateGraphics()
Dim f As Font = dg.Font
Dim sf As SizeF
' get widths for each column header
Dim dc As DataColumn
For Each dc In dt.Columns
' "W"is used as padding
sf = g.MeasureString("W" + dc.Caption, f)
cWidths.Add(sf.Width)
Next dc
' set each column with its determined width
For Each dc In dt.Columns
textColumn = New DataGridTextBoxColumn
textColumn.MappingName = dc.ColumnName
textColumn.HeaderText = "" + dc.Caption
textColumn.Width = CInt(CSng(cWidths(dc.Ordin
DGStyle.GridColumnStyles.A
sumWidths += textColumn.Width
Next dc
dg.TableStyles.Add(DGStyle
Next dt
End If
End If
End Sub 'formatDGHead