DataGrid trouble with SP2003 + CF


Today I was amazed when, after installing SP2003 SDK RTM, I opened an older Smartphone
project in VS.NET (created with a pre-RTM version of the SDK), and the compiler complained
that it could not find the DataGrid in System.Windows.Forms. And indeed, there was
none! On the other hand, it was there in my toolbox, and it was visible on my form.
What the heck was going on? Someone then told me (on a discussion list) that DataGrid
was not supported on Smartphone. Which did not explain how it got on my form earlier…

Anyway, there is a solution: since we are using the Compact Framework, and the DataGrid is supported
on the Pocket PC, why not use that one? After all, we have a common code base in .NET.
The DataGrid sits in its own assembly, System.Windows.Forms.DataGrid.dll (in the “…\CompactFrameworkSDK\v1.0.5000\Windows
CE\ directory), so I referenced that, and everything was fine.

Isn’t that cool? I LOVE .NET.

Comments (3)

  1. Joseph Alan Poirier says:

    I haven’t been able to get columns or rows to resize on a DataGrid in the Compact Framework using C#. I’ve tried a number of different approaches and converted two from VB.NET posts, but to no avail. I even found one post that states that the dataGrid does not allow for row height adjustments, which I am not very happy about. Is there any approach to loading data and adjusting the width of columns that allows both features to be utilized? (Note: I have been able to link my styles to the table, but when I was certain that I did this correctly my data was unavailable to view.)

  2. Joseph Alan Poirier says:

    I finally UNDERSTAND how the styles link to the table and the dataGrid component. Adjusting column widths are now pretty simple, but still no luck on row height.

    Here’s a clip on the widths though straight from my own archives.

    dataGrid Styles…

    Columns are locked into styles only when a table’s column name and a column style’s mapping name have been set to match.

    table column name coding

    [

    dsSched.Tables[0].Columns[0].ColumnName = "Trip Information";

    this.grid1.DataSource = dsSched.Tables[0];

    ]

    column style mapping name coding

    [

    colinfo.MappingName = "Trip Information";

    myDGTS.GridColumnStyles.Add(colinfo);

    grid1.TableStyles.Add(myDGTS);

    ]

  3. Joseph Alan Poirier says:

    using reflection works in CF. I got the row height thanks to the listing on OpenNetCF.org.