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.Enabl ed = True
Dim iType As Integer = 1
Dim iSort As Integer
Dim iBool As Boolean = False
dOrder = New DataSet("mpOrde r")
Dim tOrder As DataTable
'tBol = Nothing
tOrder = New DataTable("mpOr derTable")
Dim cRowID As DataColumn
cRowID = New DataColumn("row ID")
Dim cRowSelect As DataColumn
cRowSelect = New DataColumn("row Select")
Dim cOrderID As DataColumn
cOrderID = New DataColumn("Ord erID")
Dim cStID As DataColumn
cStID = New DataColumn("StI D")
Dim cStName As DataColumn
cStName = New DataColumn("StN ame")
Dim cscDate As DataColumn
cscDate = New DataColumn("scD ate")
Dim cscTime As DataColumn
cscTime = New DataColumn("scT ime")
Dim cStat As DataColumn
cStat = New DataColumn("sta t")
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.A dd(tOrder)
'---
'dNULL = False
dCount = 0
'
' MsgBox(rSQL)
dMain = MAPPOINTDataBos s.dMAPSelectVie w(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("rowI D") = iType.ToString
iBool = False
dOrderRow("rowS elect") = dmainRow.Item(" assigned")
dOrderRow("orde rID") = dmainRow.Item(" IF_orderID")
dOrderRow("stID ") = dmainRow.Item(" stationID")
dOrderRow("stNa me") = dmainRow.Item(" stationName")
dOrderRow("scda te") = Format(dmainRow .Item("schedule dDate"), "MM/dd/yyyy")
dOrderRow("scti me") = dmainRow.Item(" scheduledTime")
dOrderRow("stat ") = dmainRow.Item(" if_orderStatus" )
tOrder.Rows.Add (dOrderRow)
dCount += 1
Next
' Datagrid table style setup
Dim ts1 As DataGridTableSt yle
' ts1 = Nothing
ts1 = New DataGridTableSt yle
ts1.MappingName = "mporderTab le"
ts1.Alternating BackColor = Color.LightGray
ts1.AllowSortin g = False
Dim txtCol As DataGridTextBox Column
txtCol = New DataGridTextBox Column
txtCol.MappingN ame = "orderID"
txtCol.HeaderTe xt = "Order#"
txtCol.ReadOnly = True
txtCol.Width = 60
ts1.GridColumnS tyles.Add(txtCo l)
'
txtCol = New DataGridTextBox Column
txtCol.MappingN ame = "stID"
txtCol.HeaderTe xt = "Station#"
txtCol.ReadOnly = True
txtCol.Width = 70
ts1.GridColumnS tyles.Add(txtCo l)
txtCol = New DataGridTextBox Column
txtCol.MappingN ame = "stName"
txtCol.HeaderTe xt = "Station Name"
txtCol.ReadOnly = True
txtCol.Width = 240
ts1.GridColumnS tyles.Add(txtCo l)
txtCol = New DataGridTextBox Column
txtCol.MappingN ame = "scDate"
txtCol.HeaderTe xt = "Scheduled Date"
txtCol.ReadOnly = True
txtCol.Width = 80
ts1.GridColumnS tyles.Add(txtCo l)
txtCol = New DataGridTextBox Column
txtCol.MappingN ame = "scTime"
txtCol.HeaderTe xt = "Time"
txtCol.ReadOnly = True
txtCol.Width = 60
ts1.GridColumnS tyles.Add(txtCo l)
txtCol = New DataGridTextBox Column
txtCol.MappingN ame = "stat"
txtCol.HeaderTe xt = "Order Status"
txtCol.ReadOnly = True
txtCol.Width = 80
ts1.GridColumnS tyles.Add(txtCo l)
Dim boolCol As New DataGridBoolCol umn
boolCol.Mapping Name = "rowSelect"
boolCol.HeaderT ext = "Select"
boolCol.Width = 50
' boolCol.n
boolCol.AllowNu ll = False
boolCol.ReadOnl y = False
boolCol.FalseVa lue = False
boolCol.TrueVal ue = True
ts1.GridColumnS tyles.Add(boolC ol)
DataGrid1.Table Styles.Clear()
DataGrid1.Table Styles.Add(ts1)
Me.DataGrid1.Da taSource = dOrder
Me.DataGrid1.Da taMember = "mpordertab le"
Call NoAppenRow()
Catch ex As Exception
MsgBox(ex.Messa ge & ex.Source)
Catch ex As SqlException
MsgBox(ex.Numbe r & ": " & ex.Message & ex.LineNumber)
End Try
End Sub
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:et******** ******@TK2MSFTN GP09.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******** *****@TK2MSFTNG P15.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******** ********@TK2MSF TNGP14.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