<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Compact Framework</title>
        <link>http://onteorasoftware.com/category/9.aspx</link>
        <description>Compact Framework</description>
        <language>en-US</language>
        <copyright>Ken Tucker</copyright>
        <generator>Subtext Version 2.1.2.2</generator>
        <item>
            <title>Getting Windows Mobile Device ID</title>
            <link>http://blog.onteorasoftware.net/archive/2009/03/26/getting-windows-mobile-device-id.aspx</link>
            <description>&lt;p&gt;I got email today asking me how to get the device ID from a pocket pc with vb&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:d68b95e0-d5cc-407c-a09e-7f21cae8703b" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;Imports System.Text

Public Class Form1

    &amp;lt;System.Runtime.InteropServices.DllImport("coredll.dll")&amp;gt; _
Private Shared Function GetDeviceUniqueID(ByVal appdata As Byte(), ByVal cbApplictionData As Integer, ByVal dwDeviceIDVersion As Integer, ByVal deviceIDOuput As Byte(), ByRef pcbDeviceIDOutput As Integer) As Integer
    End Function

    Private Function GetDeviceId(ByVal appData As String) As Byte()

        Dim appDataBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(appData)
        Dim outputSize As Integer = 20
        Dim output(19) As Byte

        Dim result As Integer = GetDeviceUniqueID(appDataBytes, appDataBytes.Length, 1, output, outputSize)

        Return output

    End Function

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sbId As New StringBuilder

        Dim bID() As Byte = GetDeviceId("MyAppName")

        For Each b In bID
            sbId.Append(String.Format("{0:x2}", b))
        Next

        Debug.WriteLine(sbId.ToString)
    End Sub
End Class
&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p /&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;References&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a title="http://www.peterfoot.net/GetDeviceUniqueIDForVB.aspx" href="http://www.peterfoot.net/GetDeviceUniqueIDForVB.aspx"&gt;http://www.peterfoot.net/GetDeviceUniqueIDForVB.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/ms893522.aspx" href="http://msdn.microsoft.com/en-us/library/ms893522.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms893522.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blog.onteorasoftware.net/aggbug/2.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ken Tucker</dc:creator>
            <guid>http://blog.onteorasoftware.net/archive/2009/03/26/getting-windows-mobile-device-id.aspx</guid>
            <pubDate>Thu, 26 Mar 2009 19:10:32 GMT</pubDate>
            <wfw:comment>http://blog.onteorasoftware.net/comments/2.aspx</wfw:comment>
            <comments>http://blog.onteorasoftware.net/archive/2009/03/26/getting-windows-mobile-device-id.aspx#feedback</comments>
            <slash:comments>56</slash:comments>
            <wfw:commentRss>http://blog.onteorasoftware.net/comments/commentRss/2.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Compact Framework DataGrid Alternating Color</title>
            <link>http://blog.onteorasoftware.net/archive/2007/10/19/compact-framework-datagrid-alternating-color.aspx</link>
            <description>&lt;p&gt;
One of the things I miss from the Windows Forms DataGrid is the ability to have the rows alternating in color.  For this example I created a custom DataGridTextBox column which will display each other row in an different color. Basically I override the paint method to call the existing paint method with a different back color brush for every other column.
&lt;/p&gt;
 
&lt;p&gt;
 
&lt;/p&gt;
 
&lt;p&gt;
Public Class AltColorColumn&lt;br /&gt;
    Inherits DataGridTextBoxColumn  
&lt;/p&gt;
&lt;p&gt;
    Private m_AltColor As Color&lt;br /&gt;
    Public Property AltColor() As Color&lt;br /&gt;
        Get&lt;br /&gt;
            Return m_AltColor&lt;br /&gt;
        End Get&lt;br /&gt;
        Set(ByVal value As Color)&lt;br /&gt;
            m_AltColor = value&lt;br /&gt;
        End Set&lt;br /&gt;
    End Property  
&lt;/p&gt;
&lt;p&gt;
    Protected Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)&lt;br /&gt;
        If rowNum Mod 2 = 0 Then&lt;br /&gt;
            MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)&lt;br /&gt;
        Else&lt;br /&gt;
            Dim bb As New SolidBrush(m_AltColor)&lt;br /&gt;
            MyBase.Paint(g, bounds, source, rowNum, bb, foreBrush, alignToRight)&lt;br /&gt;
            bb.Dispose()&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub  
&lt;/p&gt;
&lt;p&gt;
    Public Sub New()&lt;br /&gt;
        m_AltColor = Color.LightSkyBlue&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class 
&lt;/p&gt;
&lt;p&gt;
  
&lt;/p&gt;
&lt;p&gt;
To test the column style I added the Northwind Sql Compact edition database and let it create a typed dataset for the products table for me.  While compiling the project I got a few errors in the designer generated code for the typed dataset. The compact framework does not support the dispose method for the memory stream.  You can comment out the few lines of code safely 
&lt;/p&gt;
&lt;p&gt;
  
&lt;/p&gt;
&lt;p&gt;
Finally&lt;br /&gt;
    If (Not (s1) Is Nothing) Then&lt;br /&gt;
        's1.Dispose&lt;br /&gt;
    End If&lt;br /&gt;
    If (Not (s2) Is Nothing) Then&lt;br /&gt;
        's2.Dispose&lt;br /&gt;
    End If&lt;br /&gt;
End Try  
&lt;/p&gt;
&lt;p&gt;
  
&lt;/p&gt;
&lt;p&gt;
Here is the code I used to generate a datagrid with alternating color columns. 
&lt;/p&gt;
&lt;p&gt;
Public Class Form1  
&lt;/p&gt;
&lt;p&gt;
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load&lt;br /&gt;
        Dim bs As New BindingSource&lt;br /&gt;
        Dim dt As New NorthwindDataSet.ProductsDataTable&lt;br /&gt;
        Dim ta As New NorthwindDataSetTableAdapters.ProductsTableAdapter  
&lt;/p&gt;
&lt;p&gt;
        ta.Fill(dt)  
&lt;/p&gt;
&lt;p&gt;
        bs.DataSource = dt  
&lt;/p&gt;
&lt;p&gt;
        Dim ts As New DataGridTableStyle&lt;br /&gt;
        ts.MappingName = dt.TableName  
&lt;/p&gt;
&lt;p&gt;
        Dim colName As New AltColorColumn&lt;br /&gt;
        With colName&lt;br /&gt;
            .Width = 150&lt;br /&gt;
            .HeaderText = "Product Name"&lt;br /&gt;
            .MappingName = "Product Name"&lt;br /&gt;
        End With  
&lt;/p&gt;
&lt;p&gt;
        Dim colPrice As New AltColorColumn  
&lt;/p&gt;
&lt;p&gt;
        With colPrice&lt;br /&gt;
            .Width = 75&lt;br /&gt;
            .HeaderText = "Price"&lt;br /&gt;
            .MappingName = "Unit Price"&lt;br /&gt;
            .Format = "c"&lt;br /&gt;
        End With  
&lt;/p&gt;
&lt;p&gt;
        ts.GridColumnStyles.Add(colName)&lt;br /&gt;
        ts.GridColumnStyles.Add(colPrice)&lt;br /&gt;
        DataGrid1.TableStyles.Add(ts)&lt;br /&gt;
        DataGrid1.DataSource = bs&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class 
&lt;/p&gt;
&lt;img src="http://blog.onteorasoftware.net/aggbug/48.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ken Tucker</dc:creator>
            <guid>http://blog.onteorasoftware.net/archive/2007/10/19/compact-framework-datagrid-alternating-color.aspx</guid>
            <pubDate>Fri, 19 Oct 2007 17:44:15 GMT</pubDate>
            <wfw:comment>http://blog.onteorasoftware.net/comments/48.aspx</wfw:comment>
            <comments>http://blog.onteorasoftware.net/archive/2007/10/19/compact-framework-datagrid-alternating-color.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.onteorasoftware.net/comments/commentRss/48.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Formatting the Output in a Compact Framework DataGrid</title>
            <link>http://blog.onteorasoftware.net/archive/2007/10/18/formatting-the-output-in-a-compact-framework-datagrid.aspx</link>
            <description>&lt;p&gt;
Recently I got a new windows mobile 6 Pocket PC phone.  The datagrid provided in the Compact Framework is a very limited version of the Windows Forms DataGrid.  Here is an example which will format the output of a datagrid.  The windows forms datagrid has a GetColumnAtRow which you can override to return the formatted data.  In the compact framework version you need to override the paint method to draw the formatted data in the datagrid.  Note use the columns PropertyDescriptor's GetValue method to get the cells value.  For this example I created a new column which converts true false to yes no. 
&lt;/p&gt;
&lt;p&gt;
 
&lt;/p&gt;
&lt;p&gt;
Imports System.Data 
&lt;/p&gt;
&lt;p&gt;
Public Class Form1 
&lt;/p&gt;
&lt;p&gt;
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load&lt;br /&gt;
        DataGrid1.DataSource = CreateTables()&lt;br /&gt;
        Dim ts As New DataGridTableStyle&lt;br /&gt;
        ts.MappingName = "Persons"&lt;br /&gt;
        Dim textCol As New DataGridTextBoxColumn&lt;br /&gt;
        textCol.MappingName = "Name"&lt;br /&gt;
        textCol.HeaderText = "Name"&lt;br /&gt;
        textCol.Width = 100 
&lt;/p&gt;
&lt;p&gt;
        ts.GridColumnStyles.Add(textCol)&lt;br /&gt;
        Dim boolCol As New YesNoColumn&lt;br /&gt;
        boolCol.MappingName = "USA"&lt;br /&gt;
        boolCol.HeaderText = "USA"&lt;br /&gt;
        boolCol.Width = 30 
&lt;/p&gt;
&lt;p&gt;
        ts.GridColumnStyles.Add(boolCol)&lt;br /&gt;
        DirectCast(DataGrid1.DataSource, _&lt;br /&gt;
                 DataTable).DefaultView.AllowNew = False&lt;br /&gt;
        DataGrid1.TableStyles.Add(ts)&lt;br /&gt;
    End Sub 
&lt;/p&gt;
&lt;p&gt;
    Private Function CreateTables() As DataTable&lt;br /&gt;
        Dim dtVBReg As New DataTable("Persons")&lt;br /&gt;
        dtVBReg.Columns.Add("Name")&lt;br /&gt;
        dtVBReg.Columns.Add("USA", GetType(System.Boolean))&lt;br /&gt;
        dtVBReg.LoadDataRow(New Object() {"Ken Tucker", True}, True)&lt;br /&gt;
        dtVBReg.LoadDataRow(New Object() {"Cor Ligthert", False}, True)&lt;br /&gt;
        Return dtVBReg&lt;br /&gt;
    End Function&lt;br /&gt;
End Class 
&lt;/p&gt;
&lt;p&gt;
Public Class YesNoColumn&lt;br /&gt;
    Inherits DataGridTextBoxColumn 
&lt;/p&gt;
&lt;p&gt;
    Protected Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)&lt;br /&gt;
        'clear the cell&lt;br /&gt;
        g.FillRectangle(backBrush, bounds) 
&lt;/p&gt;
&lt;p&gt;
        Dim s As String&lt;br /&gt;
        ' Get the cells value&lt;br /&gt;
        s = Me.PropertyDescriptor.GetValue(source.List(rowNum)).ToString 
&lt;/p&gt;
&lt;p&gt;
        If s.ToLower = "true" Then s = "Yes" Else s = "No" 
&lt;/p&gt;
&lt;p&gt;
        Dim r As Rectangle = bounds&lt;br /&gt;
        r.Inflate(0, -1)&lt;br /&gt;
        g.DrawString(s, New Font("Arial", 8, FontStyle.Regular), foreBrush, r)&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class 
&lt;/p&gt;
&lt;img src="http://blog.onteorasoftware.net/aggbug/49.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ken Tucker</dc:creator>
            <guid>http://blog.onteorasoftware.net/archive/2007/10/18/formatting-the-output-in-a-compact-framework-datagrid.aspx</guid>
            <pubDate>Fri, 19 Oct 2007 01:57:33 GMT</pubDate>
            <wfw:comment>http://blog.onteorasoftware.net/comments/49.aspx</wfw:comment>
            <comments>http://blog.onteorasoftware.net/archive/2007/10/18/formatting-the-output-in-a-compact-framework-datagrid.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.onteorasoftware.net/comments/commentRss/49.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>