Welcome to MSDN Blogs Sign in | Join | Help

.Net Compact Framework V2 Service Pack 1 Data Grid control enhancements.

Data Grid control available on Compact Framework is extensively used to represent various data. It is fast as only visible rows are retrieved from data source and relatively easy to use.

However, Compact Framework version of the Data Grid is not as extensible as its desktop counterpart and lacking some key features developers needed to create modern application.

Among most requested features is the ability to format data displayed by Data Grid, check box column availability and inability to use different colors for odd and even rows (even though very complex solution for last one is available here).

Compact framework V2 Service Pack 1 introduces minor, but very useful extensions to address these issues either directly (e.g. data formatting) or by allowing customer to perform custom cell drawings to achieve desired results.

Let's take a look at these additions:

Class Name

Method or Property

Functionality

DataGridColumnStyle

public virtual PropertyDescriptor PropertyDescriptor { set; get; }

Property descriptor allows access to this column data in the data source so it could be processed as needed.

DataGridColumnStyle

protected internal virtual void Paint(Graphics g,Rectangle bounds,CurrencyManager source,int rowNum,Brush backBrush,Brush foreBrush,bool alignToRight);

Protected Paint() method is called as cell is drawn. Overriding it allows representing data from data source in any way imaginable. Colors, fonts, formatting, alignment, pictures and more - anything is possible as long as it can be painted.

CurrencyManager and row number along with PropertyDescriptor allows fetching data from data source to convert and format the way you want.

DataGridTextBoxColumn

public string Format { set; get; }

Format string to be used to format data in the column. To be used the same way as on desktop or in simple data binding.

DataGridTextBoxColumn

public IFormatProvider FormatInfo { set; get; }

Format provider to be used to format data in the column. To be used the same way as on desktop or in simple data binding.

Format related properties are very easy to use, they can be set via designers the same way it's done on the desktop.

Overriding Paint() is not hard as well, but requires some coding. To illustrate how that can be done, I've created small sample which shows sample data in several custom columns.

To use the sample, please download it here, rename the file so it has .msi extension and install it on to your PC. You would also need .Net Compact Framework V2 SP1 installed, currently available in Beta here.

After sample is installed, it is accessible via Start Menu. Please make sure to rebuild the solution before browsing the code otherwise Visual Studio would be unable to find the assembly with custom Table Styles and would show errors. Enjoy.

[Author: Ilya Tumanov]

Published Tuesday, April 25, 2006 1:52 PM by NetCFTeam
Attachment(s): CustomDataGridSample.msi

Comments

# .NET Compact Framework 2.0 Service Pack 1 Beta

Tuesday, April 25, 2006 6:13 PM by Олег Михайлик
Скоро выйдет финальный SP1, а пока список улучшений, пояснение по части DataGrid

# The Mobile Minute 139

Friday, April 28, 2006 1:01 AM by Nino.Mobile
 
Software / Hardware 

ActiveSync 4.2 Beta Preview has been released
SlingPlayer Mobile...

# .NET CF2 SP1 angekündigt

Friday, April 28, 2006 3:16 AM by .NET (Compact) Framework

# .NET Compact Framework 2.0 SP1 发布了

Saturday, March 17, 2007 7:27 AM by Bob Li

前段时间发布了Beta版,还没有来的及试用,现在终于发布了正式版。

# DataGrid with a custom header and selection.

Saturday, November 10, 2007 7:59 PM by Alex Yakhnin - Mobility Consultant, Former MVP

One of the questions that has recently come up on the .Net CF MSDN forums was on how to create a custom

# DataGrid with a custom header and selection.

Saturday, November 10, 2007 8:08 PM by Noticias externas

One of the questions that has recently come up on the .Net CF MSDN forums was on how to create a custom

# MSDN Blog Postings » DataGrid with a custom header and selection.

# Having checkboxes etc in a .NET CF 2.0 datagrid - Sharing the Knowledge

# Image in cell of Datagrid | keyongtech

Sunday, January 18, 2009 11:43 AM by Image in cell of Datagrid | keyongtech

# ListView Details RowHigh | hilpers

Tuesday, January 20, 2009 10:55 AM by ListView Details RowHigh | hilpers

# NET Compact Framework Team Net Compact Framework V2 Service Pack 1 | Portable Greenhouse

Anonymous comments are disabled
 
Page view tracker