Formatting the cell of DataGrid for Pocket PC

M

Mark

I need to format the cells of one Column of DataGrid, on the Pocket PC
with Windows CE vers. 4.2
The problem is that in the libreries of C# for Windows CE, there isn't
the paint method of DataGridTextBoxColumn, which i used for paint the
cell.
Howewer i don't know the alternative metodology to format each cell of
one column, differently.
I help you for some council!!!!!!!!!!!
 
J

joelcochran

Mark said:
I need to format the cells of one Column of DataGrid, on the Pocket PC
with Windows CE vers. 4.2
The problem is that in the libreries of C# for Windows CE, there isn't
the paint method of DataGridTextBoxColumn, which i used for paint the
cell.
Howewer i don't know the alternative metodology to format each cell of
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
 
M

Mark

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
 
J

joelcochran

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
 
M

Mark

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top