DEVBUZZ Homepage A Powerful New Grid Control Optimized for the .NET Compact Framework
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | .NET Compact Framework

A Powerful New Grid Control Optimized for the .NET Compact Framework
Written by Radomir Vozar  [author's bio]  [read 31797 times]
Edited by Derek

.NET Compact Framework   

Page 1 

A Powerful New Grid Control Optimized for the .NET Compact Framework

The grid control is a standard component of almost every desktop and mobile application and although Visual Studio .NET includes the DataGrid control, its functionality is very limited and usage quite problematic especially in mobile application projects. The Resco SmartGrid .NET is a powerful control designed specifically for mobile devices. In addition to the standard grid functionality the SmartGrid supports advanced graphics features such as column and cell customizations as well as very efficient data handling.

In this article Radomir presents the basic features of this control and the way SmartGrid works in a smart device application project. To this end I will create a sample form which loads product sales data from a SQLCE database and displays them in a stylish grid complete with graphics and customized cells.

Quick data loading

My local database contains only one table with three columns:

  • ProductName – the name of the product
  • Sales – total yearly product sales in USD
  • Change – sales change in comparison to the previous year

I will use the DBConnector object to load data to my SmartGrid. This object significantly simplifies my work. The only thing I need to do is to set its ConnectionString and CommandText properties and then call the LoadData method which creates all columns and loads the data to the SmartGrid.

Me.SmartGrid1.DbConnector.ConnectionString = _
      "Data Source = \Program Files\DevBuzzSample\Northwind.sdf;"
Me.SmartGrid1.DbConnector.CommandText = "SELECT * FROM Sales"
Me.SmartGrid1.LoadData(True)

This works well until the "Select" command returns too many rows then the loading process becomes extremely slow, especially on a Pocket PC owing to the limited CPU and memory constraints of mobile devices. This can often translate into a certain degree of frustration to the users of my application. To address this performance issue the SmartGrid utilizes a proprietary quick data loading technique. The only thing I need to do is set the DelayLoad property.

Me.SmartGrid1.DelayLoad = True

This option ensures that the SmartGrid only loads data for the rows which are visible in the grid. For example, if my Select returns 1000 rows, the LoadData method loads only the first 15 to 20 rows (those which are visible in the SmartGrid). The remaining rows are only read after the user clicks on the scroll bar.

Using this approach the SmartGrid can be filled within a second, no matter how much data the SelectCommand returns.

Advanced graphics capabilities

In the next part of my article I will modify the appearance of my SmartGrid.

Basic look and feel customizations can be achieved by setting the color properties of standard, alternative, header and selected cells all of which can be done in the Visual Studio Designer using the Properties Window.

If I want to perform more advanced customizations I need to create grid columns and grid styles which I will use for my columns or particular cells. This can be also done in the Designer.

In my sample I create three columns named ProductName, Sales and Change and set their basic properties such as DataMember, HeaderText, Width, etc. Now say I want to keep the default simple style of the first two columns but need to add some graphics to the Change column. I can do this thanks to the CustomCell Event. All I need to do is set the CustomCell property of this column to True. This setting causes the CustomCell Event to be raised for every cell in the Change column.

Finally I need to write the code for this Event along these lines. In case of a positive value I’ll change the color to blue and draw an up arrow image in the left part of the cell, while in case of negative values, I’ll use the red color and a down arrow image.

For this type of customization I need to create two new styles Number_blue and Number_red and set their ForeColor property to blue (or red respectively) and ImagePosition property to Left. I also need to add the ImageList control and both arrow images to my form. The CustomCell Event code will look like this:

Private Sub SmartGrid1_CustomizeCell(ByVal sender As Object, _
                ByVal e As Resco.Controls.SmartGrid.CustomizeCellEventArgs) _
                Handles SmartGrid1.CustomizeCell

    If e.Cell.Header = False Then
        If e.Cell.Column.DataMember = "Change" Then

            ' Format the Text property
            e.Cell.Text = FormatPercent(e.Cell.Data, 0)

            ' Format the Style and Image properties
            If e.Cell.Data > 0 Then
                e.Cell.Style = Me.SmartGrid1.Styles("Number_blue")
                e.Cell.Image = Me.ImageList1.Images(0)
            Else
                e.Cell.Style = Me.SmartGrid1.Styles("Number_red")
                e.Cell.Image = Me.ImageList1.Images(1)
            End If

        End If
    End If

End Sub

And this is what my final SmartGrid sample form looks like.

Resco SmartGrid Control

In conclusion

This is just a brief explanation of the basic SmartGrid features. More advanced functionality is available, such as:

  • Use the location and size properties of the cell to display an edit component allowing direct data modification.
  • Use data binding to all standard data sources like DataTable, DataView, ArrayList...
  • Use manual data loading through the Rows collection.
  • Save the layout of the control to an XML Template and load it during runtime.
  • Use the Advanced SmartGrid Designer

Click here to buy the SmartGrid .NET Control - optimized for .NET Conpact Framework.

Back to .NET Compact Framework | [Article Index]

 

Back to the top of the page.
Franson GPS tools for the Pocket PC Chris De Herrera's Windows CE Website Windows CE News & Information Source RESCO Software discounts
Copyright ©2000-2008 by DEVBUZZ.COM, Inc., TX. USA.