Cor;
I spent a great deal of time trying almost everything and still got the same
results. I added a boolean column (datatype = bit) to the table and set
value to zero for all rows. The column still displays a checkmark and
behaves exactly the same way (doubleclick twice changes the check stat but
goes back to dim with checkmark as soon as the cursor leaves the row).
below is my code. Please take a look and let me know what I did wrong.
Thanks a million
Bill
-------------------------
DataGrid1.Enabled = True
Dim iType As Integer = 1
Dim iSort As Integer
Dim iBool As Boolean = False
dOrder = New DataSet("mpOrder")
Dim tOrder As DataTable
'tBol = Nothing
tOrder = New DataTable("mpOrderTable")
Dim cRowID As DataColumn
cRowID = New DataColumn("rowID")
Dim cRowSelect As DataColumn
cRowSelect = New DataColumn("rowSelect")
Dim cOrderID As DataColumn
cOrderID = New DataColumn("OrderID")
Dim cStID As DataColumn
cStID = New DataColumn("StID")
Dim cStName As DataColumn
cStName = New DataColumn("StName")
Dim cscDate As DataColumn
cscDate = New DataColumn("scDate")
Dim cscTime As DataColumn
cscTime = New DataColumn("scTime")
Dim cStat As DataColumn
cStat = New DataColumn("stat")
Try
tOrder.Columns.Add(cRowID)
tOrder.Columns.Add(cRowSelect) 'checkbox column
tOrder.Columns.Add(cOrderID)
tOrder.Columns.Add(cStID)
tOrder.Columns.Add(cStName)
tOrder.Columns.Add(cscDate)
tOrder.Columns.Add(cscTime)
tOrder.Columns.Add(cStat)
dOrder.Tables.Add(tOrder)
'---
'dNULL = False
dCount = 0
'
' MsgBox(rSQL)
dMain = MAPPOINTDataBoss.dMAPSelectView(rSQL)
If dMain.Tables(0).Rows.Count = 0 Then
Beep()
Call DisplayStatus("No records found! Nothing to display.", "red")
Exit Sub
Else
Call DisplayStatus("Total Order Records: " & (dMain.Tables(0).Rows.Count),
"red")
End If
Dim dOrderRow, dmainRow As DataRow
For Each dmainRow In dMain.Tables(0).Rows
dOrderRow = tOrder.NewRow
dOrderRow("rowID") = iType.ToString
iBool = False
dOrderRow("rowSelect") = dmainRow.Item("assigned")
dOrderRow("orderID") = dmainRow.Item("IF_orderID")
dOrderRow("stID") = dmainRow.Item("stationID")
dOrderRow("stName") = dmainRow.Item("stationName")
dOrderRow("scdate") = Format(dmainRow.Item("scheduledDate"), "MM/dd/yyyy")
dOrderRow("sctime") = dmainRow.Item("scheduledTime")
dOrderRow("stat") = dmainRow.Item("if_orderStatus")
tOrder.Rows.Add(dOrderRow)
dCount += 1
Next
' Datagrid table style setup
Dim ts1 As DataGridTableStyle
' ts1 = Nothing
ts1 = New DataGridTableStyle
ts1.MappingName = "mporderTable"
ts1.AlternatingBackColor = Color.LightGray
ts1.AllowSorting = False
Dim txtCol As DataGridTextBoxColumn
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "orderID"
txtCol.HeaderText = "Order#"
txtCol.ReadOnly = True
txtCol.Width = 60
ts1.GridColumnStyles.Add(txtCol)
'
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "stID"
txtCol.HeaderText = "Station#"
txtCol.ReadOnly = True
txtCol.Width = 70
ts1.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "stName"
txtCol.HeaderText = "Station Name"
txtCol.ReadOnly = True
txtCol.Width = 240
ts1.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "scDate"
txtCol.HeaderText = "Scheduled Date"
txtCol.ReadOnly = True
txtCol.Width = 80
ts1.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "scTime"
txtCol.HeaderText = "Time"
txtCol.ReadOnly = True
txtCol.Width = 60
ts1.GridColumnStyles.Add(txtCol)
txtCol = New DataGridTextBoxColumn
txtCol.MappingName = "stat"
txtCol.HeaderText = "Order Status"
txtCol.ReadOnly = True
txtCol.Width = 80
ts1.GridColumnStyles.Add(txtCol)
Dim boolCol As New DataGridBoolColumn
boolCol.MappingName = "rowSelect"
boolCol.HeaderText = "Select"
boolCol.Width = 50
' boolCol.n
boolCol.AllowNull = False
boolCol.ReadOnly = False
boolCol.FalseValue = False
boolCol.TrueValue = True
ts1.GridColumnStyles.Add(boolCol)
DataGrid1.TableStyles.Clear()
DataGrid1.TableStyles.Add(ts1)
Me.DataGrid1.DataSource = dOrder
Me.DataGrid1.DataMember = "mpordertable"
Call NoAppenRow()
Catch ex As Exception
MsgBox(ex.Message & ex.Source)
Catch ex As SqlException
MsgBox(ex.Number & ": " & ex.Message & ex.LineNumber)
End Try
End Sub
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
B ill,
You have to set the boolean columns in a for each after that you have
created them to false
\\\
For each dr as datarow in dt
dr("mycolumn") = false
Next
///
To see if they are checked you do in fact in the same way or in a for
index loop.
I hope this helps,
Cor
"Bill Nguyen" <bi*****************@jaco.com> schreef in bericht
news:Oo*************@TK2MSFTNGP15.phx.gbl... Thanks Cor.
I was able to add the checkbox in front of each row. There are 2 problems
though:
1. The box is dimmed and has the check mark in it. I want the box
unchecked (default value = FALSE). When I click on it, I can check or
uncheck the box, but as soon as the cursor move to the next row, the box
goes back to its original state (dimmed with box checked!)
2. This column doesn't come from the datasource for the remaining
columns. How do I select only rows (in the datasource) with the checkbox
checked?
Thanks again
Bill
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:Oi****************@TK2MSFTNGP14.phx.gbl... Bill,
A checkbox is one of the most standard ones, you don't even have to do
something for it, it is for a boolean column in the underlying
datasource.
If it is not already in your table, than just add it.
This is not even needed, however to see it with styles. Look at the Add
of the boolean column in the bottom of this sample.
http://www.vb-tips.com/default.aspx?...6-3300b2215049
I hope this helps,
Cor