Color datagrid rows using .net 3.5 COMPACT
Posted on 2010-11-30
I am trying to set the colours of a datagrid based on a value.
Trouble is the .net 3.5 COMPACT framework is different to what I am used to.
Normally to colour the rows I would use something like .......
Dim r As Integer
For r = 0 To MYDATAGRID.Rows.Count - 1
If Not IsDBNull(MYDATAGRID.Rows(r).Cells(11).Value) Then
If MYDATAGRID.Rows(r).Cells(11).Value = "True" Then
MYDATAGRID.Rows(r).DefaultCellStyle.BackColor = Color.Yellow
MYDATAGRID.Rows(r).DefaultCellStyle.BackColor = Color.White
Trouble is with the .net 3.5 Compact framework, I get the error
'Rows' is not a member of 'System.Windows.Forms.DataGrid'.
Does any one have an example of how to colour a datagrid row using the compact framework ?
The project is being delployed on a Windows Mobile 6 Smart Device, if that helps ?
This is the code I am using to populate the grid
Protected Sub Populate_Customer_List()
' Display the Loaded Customer List
Dim MyConn As New SqlCeConnection(MyLocalConnString)
Dim MyCmd As SqlCeCommand = MyConn.CreateCommand()
Dim MyDataSet As New Data.DataSet()
Dim MyDataAdapter As New SqlCeDataAdapter(MyCmd)
Dim MySQl As String
MySQl = "select max(deliveryorder) As DeliveryOrder, "
MySQl = MySQl & "custnmbr, "
MySQl = MySQl & "max(shiptoname), "
MySQl = MySQl & "max(zipcode), "
MySQl = MySQl & "max(received), "
MySQl = MySQl & "max(cast(completed as nvarchar))"
MySQl = MySQl & "from bigk_myt_pda_out_lines "
MySQl = MySQl & "where custnmbr <> 'overs' "
MySQl = MySQl & "group by custnmbr "
MySQl = MySQl & "order by DeliveryOrder "
MyCmd.CommandText = MySQl
MyCmd.CommandType = Data.CommandType.Text
DG_Customer_List.DataSource = MyDataSet.Tables(0)
MyRowCount = MyDataSet.Tables(0).Rows.Count
Thanks in advance