473,734 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add checkbox to items in a datagrid

I need to add a checkbox in front of all the rows in a datagrid so that
users can select/unselect them.

Any help is greatly appreciated!

Bill
Nov 30 '05 #1
6 1715
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
Nov 30 '05 #2
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

Nov 30 '05 #3
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


Dec 1 '05 #4
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



Dec 7 '05 #5
Bill,

Can you next time first copy the code in a notebook, and than copy it back
and in the message. In this way it is unreadable.

I think that you have tried a lot to fullfil your goal, see the row above,
normally the scheme should come from your fill, (what is not in the code so
I assume that is that function mappointdatabos s.

However if you declare a table than you have to tell what kind of columns it
are (I never do that if it are only strings in samples).

By instance like this.
\\\
Dim cscDate As New DataColumn("scD ate", GetType(System. DateTime))
Dim cRowSelect As New DataColumn("row Select", GetType(System. Boolean))
///

Now the datagrid knows that it is a boolean column and will act acoording to
that.

(I do not know it this is the answer, however as start and if not than
please the code back as I said, (including this of course).

I hope this helps sofar

Cor
"Bill nguyen" <bi************ *****@jaco.com> schreef in bericht
news:eb******** ********@TK2MSF TNGP11.phx.gbl. ..
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



Dec 7 '05 #6
Cor;

Those dim's are fantastic! Thank for your help!!!

Bill

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:eP******** ********@TK2MSF TNGP14.phx.gbl. ..
Bill,

Can you next time first copy the code in a notebook, and than copy it back
and in the message. In this way it is unreadable.

I think that you have tried a lot to fullfil your goal, see the row above,
normally the scheme should come from your fill, (what is not in the code
so I assume that is that function mappointdatabos s.

However if you declare a table than you have to tell what kind of columns
it are (I never do that if it are only strings in samples).

By instance like this.
\\\
Dim cscDate As New DataColumn("scD ate", GetType(System. DateTime))
Dim cRowSelect As New DataColumn("row Select", GetType(System. Boolean))
///

Now the datagrid knows that it is a boolean column and will act acoording
to that.

(I do not know it this is the answer, however as start and if not than
please the code back as I said, (including this of course).

I hope this helps sofar

Cor
"Bill nguyen" <bi************ *****@jaco.com> schreef in bericht
news:eb******** ********@TK2MSF TNGP11.phx.gbl. ..
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
>



Dec 7 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4160
by: iforsyth | last post by:
Have a paging datagrid with a checkbox control in column(0). ViewState is enabled. I check the checkbox in first row of the grid on a page and then the program hits this event: Private Sub dgRegGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgRegGrid.PageIndexChanged I then do a loop to check the checkbox state.
1
1220
by: Andre | last post by:
Hi, I need some help with automatically generated checkbox in my datagrid, i'm searching everywhere and can't find a way to do this. In my datagrid i will always have more than one line, with one checkbox on each line (each line is an option for our costumers). But i want to : - have autopostback set to true only on the first (or any other,
2
6055
by: Rekha | last post by:
Hi I have datagrid with 5 items. Out of which 1 items are checkboxes. The bool column(checkbox column ) in added in datagrid. The rest of Data is binded dynamically to the datagrid Based on some values from the database I have to check or uncheck the checkbox in the datatgrid. Does any one know how to do this in windows form?
10
2444
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox control in a datagrid? Now I have a Select column but the problem is that the user needs to select more than one record and send them all to print, instead of being one by one like is now with the Select column. Another question, is it possible to...
2
5521
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox and subcategory check boxes and click on submit button , I have to retrieve the corresponding categoryid and subcategory id, so that I can store it to a table. I am getting the categoryid but I am failing to get subcategoryid(actually I don't know...
9
1594
by: Rekha | last post by:
The data is filled in datagrid. I want to know how to add a checkbox column in datagrid? In the runtime, checkbox is checked then instead of checkbox value the (caseID )column value is retained. I know there is a lot of article on datagrid with checkbox but nothing helped me . Can anyone help me how to proceed ? Thanks
8
16612
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below the repeater. When clicked, it is supposed to
1
1333
by: arun.hallan | last post by:
Hi, I have two columns in a datagrid that are filled with checkboxes. I want one checkbox in a row to be checked when the corresponding checkbox is checked. I've added an OnCheckedChanged event to the checkbox and implemented the method with the following code:
10
5206
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named 'CheckAllRows' on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the...
4
7501
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to checkchekboxes and click the Delete button. That will show a confirmation dialog message with the items they choose to delete.
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.