Thus...Visual Basic>Smart Device>Windows CE 5.0 project.
I've been looking for examples on how to set the column width in a
datagrid. I'm populating the datagrid with a collection and assigning that
collection to the datasource. The data shows up and all looks well, but the
columns are all the same width and left aligned. I'm down to the
aesthetics.
I've given this a try too, but no luck.
Dim ts As New DataGridTableStyle
ts.MappingName = "Unchecked"
Dim s As DataGridColumnStyle = New DataGridTextBoxColumn
s.MappingName = "Route"
s.HeaderText = "Rte"
s.Width = 30
ts.GridColumnStyles.Add(s)
Me.dgUnchecked.TableStyles.Add(ts)
How do I set the column widths either programmically or in design mode and
how can I modify alignment?
If you are sure, that your mapping names are correct then TableStyles
should apply.
if not sure of the mapping name, try this
ts.MappingName = dgUnchecked.DataSource.GetType().Name;
Try this too,
//Do clear default table style before applying customized
Me.dgUnchecked.TableStyles.Clear();
Me.dgUnchecked.TableStyles.Add(ts)
Better use word "DataGridTableStyle" and do a google compact
framework
group search
http://groups.google.com/advanced_group_search
you will get lots of threads discussed the same topic and few will
really help you.
Cheers,
Arun
This line did it for me:
ts.MappingName = dgUnchecked.DataSource.GetType().Name;
I can now add styles to each column...which I am grateful for your help.
The width of the grid is wider than the width of the screen and by defaults
scrollbars show up which is what I want. The datagrid is docked (Fill)
inside a tab control. Adding only a couple of columns works great, but not
when modifying column widths (px) of (25, 100, 50, 50, 200, 200) on a screen
width of 240, the scrollbars go away and there is no way to view the columns
that are off the screen. It isn't critical to have colmun widths set, so
I'll drop that enhancement for now. Now its more of a want to know how to
do it than a need. Column Alignment wasn't available either.
Thanks, Arun...I appreciate the help.