> I need to format the cells of one Column of DataGrid, on the Pocket PC
> with Windows CE vers. 4.2
[quoted text clipped - 4 lines]
> one column, differently.
> I help you for some council!!!!!!!!!!!
Create a DataGirdTableStyle, then create and add DataGridColumn objects
to it, each with its own formatting. Here is a working sample from a
Mobile5 app I have written:
<code>
this.dt = new DataTable();
DataColumn col_seq = new DataColumn("Seq",
Type.GetType("System.Int32"));
this.dt.Columns.Add(col_seq);
DataColumn col_desc = new DataColumn("Description",
Type.GetType("System.String"));
this.dt.Columns.Add(col_desc);
DataColumn col_value = new DataColumn("Value",
Type.GetType("System.Decimal"));
this.dt.Columns.Add(col_value);
DataGridTableStyle style = new DataGridTableStyle();
DataGridTextBoxColumn SeqColumn = new
DataGridTextBoxColumn();
SeqColumn.MappingName = "Seq";
SeqColumn.HeaderText = "Seq";
SeqColumn.Width = 50;
style.GridColumnStyles.Add(SeqColumn);
DataGridTextBoxColumn LhsColumn = new
DataGridTextBoxColumn();
LhsColumn.MappingName = "Description";
LhsColumn.HeaderText = "Description";
LhsColumn.Width = 270;
style.GridColumnStyles.Add(LhsColumn);
DataGridTextBoxColumn ValueColumn = new
DataGridTextBoxColumn();
ValueColumn.MappingName = "Value";
ValueColumn.HeaderText = "Value";
ValueColumn.Width = 100;
style.GridColumnStyles.Add(ValueColumn);
this.dg.TableStyles.Add(style);
this.dg.DataSource = this.dt;
</code>
HTH,
Joel
Mark - 20 Jul 2006 11:39 GMT
Hi Joel
you're nice, but my problem is formatting the each cell of DataGrid.
I used your council, but, with only the methods of
DataGridTextBoxColumn, i don't paint the background of the each cell,
so i need to find a method which i can use to format the background of
each cells of DataGrid. Partucularly, i found the method paint of
DataGridTextBoxColumn, but il isn't in the C# libraries for Windows CE.
Thank you very much!
Waiting your answear.
hello Mark
joelcochran@gmail.com - 25 Jul 2006 15:05 GMT
Hi Mark,
Sorry, by formatting the cells I thought you meant sizing, naming, etc.
I believe that if you want to format the individual cells you may need
to extend DataGridTextBoxColumn (if it isn't sealed) and override the
OnPaint method. Otherwise, I don't know how you would do what you
want.
Best of luck,
Joel
> Hi Joel
>
[quoted text clipped - 10 lines]
>
> hello Mark
Mark - 26 Jul 2006 09:01 GMT
Hi Joel
but i find absurd that there isn't a specific method to paint the
individual cells. I noticed that the selection of row of DataGrid was
painted in blue color and i thought that it had to exist a particular
good method, on the pocket PC, to paint the background of cell. If
you'll have some answer in the future, i would like to know its.
Bye Bye
Mark