473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Radiobuttons Databind

I have looked and searched. What good is the databind property on
Radiobuttons? How does one go about actually using it? What is a good
resource on this? I understand that I can easily get/set the information I
need programmatically, but what about the databind property I just don't
understand it's value.



Rourke Eleven
Cthulhu saves sinners - in case he's hungry later!
Nov 20 '05 #1
11 4627
OK, to illustrate. Create an access database with two fields in it. A ID (
PK ) field and a Yes/No field called 'Data'. Add Three records with the
centre on unchecked.

Using server explorer, drag the table to the form and create a DataSet
DS(DS1) using the wizard.

Drag a Checkbox onto your form (cb1) and a button (btnUP), put the following
code in and run it. You will see by clicking the button once the CB
disapears and then once again, it appears. You have bound the Data to the
control and are using the binding context of the form to move through the
bound records.

Voilla !!

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DA.Fill(Ds1)
CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
End Sub

Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUP.Click
Dim bm As BindingManagerBase
bm = Me.BindingContext.Item(Ds1.Tables(0))
bm.Position += 1
End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
I have looked and searched. What good is the databind property on
Radiobuttons? How does one go about actually using it? What is a good
resource on this? I understand that I can easily get/set the information I need programmatically, but what about the databind property I just don't
understand it's value.



Rourke Eleven
Cthulhu saves sinners - in case he's hungry later!

Nov 20 '05 #2
For all others this is regarding VB.Net Windows Forms not ASP.Net

Terry,

Ok I understand that but what about in the the context of a group of
Radiobuttons and using mutual exclusivity.

For example I have field in a database that I want to have the values of 0,
1, 2 or 3 (or actually any values I want to Assign)

So Radiobutton 1 sets the value to 0 and so on.

How does databinding work in this instance?

Or even if I had a field in a database that was bool and I wanted to use
Radiobuttons instead of a Checkbox.

I would love to be able to set all of this with properties instead of
programmatically with a decision stucture and then binding.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
OK, to illustrate. Create an access database with two fields in it. A ID (
PK ) field and a Yes/No field called 'Data'. Add Three records with the
centre on unchecked.

Using server explorer, drag the table to the form and create a DataSet
DS(DS1) using the wizard.

Drag a Checkbox onto your form (cb1) and a button (btnUP), put the following code in and run it. You will see by clicking the button once the CB
disapears and then once again, it appears. You have bound the Data to the
control and are using the binding context of the form to move through the
bound records.

Voilla !!

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DA.Fill(Ds1)
CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
End Sub

Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUP.Click
Dim bm As BindingManagerBase
bm = Me.BindingContext.Item(Ds1.Tables(0))
bm.Position += 1
End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
I have looked and searched. What good is the databind property on
Radiobuttons? How does one go about actually using it? What is a good
resource on this? I understand that I can easily get/set the
information I
need programmatically, but what about the databind property I just don't
understand it's value.



Rourke Eleven
Cthulhu saves sinners - in case he's hungry later!


Nov 20 '05 #3
Hi,

Maybe this is what you are looking for.
http://msdn.microsoft.com/msdnmag/is...s/default.aspx

Ken
--------------

"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl:
I have looked and searched. What good is the databind property on
Radiobuttons? How does one go about actually using it? What is a good
resource on this? I understand that I can easily get/set the information
I
need programmatically, but what about the databind property I just don't

understand it's value.



Rourke Eleven
Cthulhu saves sinners - in case he's hungry later!


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Nov 20 '05 #4
OK, that was not clear in your OP. Ken posted link but I have not checked
that out, if you are still having difficulties by tomorrow, I'll try and
help

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
For all others this is regarding VB.Net Windows Forms not ASP.Net

Terry,

Ok I understand that but what about in the the context of a group of
Radiobuttons and using mutual exclusivity.

For example I have field in a database that I want to have the values of 0, 1, 2 or 3 (or actually any values I want to Assign)

So Radiobutton 1 sets the value to 0 and so on.

How does databinding work in this instance?

Or even if I had a field in a database that was bool and I wanted to use
Radiobuttons instead of a Checkbox.

I would love to be able to set all of this with properties instead of
programmatically with a decision stucture and then binding.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:Ok**************@TK2MSFTNGP12.phx.gbl...
OK, to illustrate. Create an access database with two fields in it. A ID ( PK ) field and a Yes/No field called 'Data'. Add Three records with the centre on unchecked.

Using server explorer, drag the table to the form and create a DataSet
DS(DS1) using the wizard.

Drag a Checkbox onto your form (cb1) and a button (btnUP), put the

following
code in and run it. You will see by clicking the button once the CB
disapears and then once again, it appears. You have bound the Data to the control and are using the binding context of the form to move through the bound records.

Voilla !!

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DA.Fill(Ds1)
CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
End Sub

Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUP.Click
Dim bm As BindingManagerBase
bm = Me.BindingContext.Item(Ds1.Tables(0))
bm.Position += 1
End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
I have looked and searched. What good is the databind property on
Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set the

information
I
need programmatically, but what about the databind property I just don't understand it's value.



Rourke Eleven
Cthulhu saves sinners - in case he's hungry later!



Nov 20 '05 #5
Ken's answer is great and I think I will use it, but it still doesn't answer
1 of my questions. Why have databinding on Radiobuttons? What is its use?

I can't think of a time that I would have just a single radiobutton on a
form. As the Article that Ken sent points out Microsoft needs to think
about building in a control that does what Duncan Mackenzie does in his user
control. Make a Radiobutton ListControl with a simple interface like that
of a Web Combobox which you can input your own Members with a Text/values in
a listcontrol container or you can databind.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
OK, that was not clear in your OP. Ken posted link but I have not checked
that out, if you are still having difficulties by tomorrow, I'll try and
help

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
For all others this is regarding VB.Net Windows Forms not ASP.Net

Terry,

Ok I understand that but what about in the the context of a group of
Radiobuttons and using mutual exclusivity.

For example I have field in a database that I want to have the values of 0,
1, 2 or 3 (or actually any values I want to Assign)

So Radiobutton 1 sets the value to 0 and so on.

How does databinding work in this instance?

Or even if I had a field in a database that was bool and I wanted to use
Radiobuttons instead of a Checkbox.

I would love to be able to set all of this with properties instead of
programmatically with a decision stucture and then binding.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
OK, to illustrate. Create an access database with two fields in it. A ID (
PK ) field and a Yes/No field called 'Data'. Add Three records with the centre on unchecked.

Using server explorer, drag the table to the form and create a
DataSet DS(DS1) using the wizard.

Drag a Checkbox onto your form (cb1) and a button (btnUP), put the

following
code in and run it. You will see by clicking the button once the CB
disapears and then once again, it appears. You have bound the Data to

the control and are using the binding context of the form to move through the bound records.

Voilla !!

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DA.Fill(Ds1)
CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
End Sub

Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUP.Click
Dim bm As BindingManagerBase
bm = Me.BindingContext.Item(Ds1.Tables(0))
bm.Position += 1
End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
> I have looked and searched. What good is the databind property on
> Radiobuttons? How does one go about actually using it? What is a good > resource on this? I understand that I can easily get/set the

information
I
> need programmatically, but what about the databind property I just don't > understand it's value.
>
>
>
>
>
>
>
> Rourke Eleven
> Cthulhu saves sinners - in case he's hungry later!
>
>



Nov 20 '05 #6
This is great. It will work for what I am doing. Makes me wonder why
Microsloth didn't do it first.

Thanks Ken!!!
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
Hi,

Maybe this is what you are looking for.
http://msdn.microsoft.com/msdnmag/is...s/default.aspx

Ken
--------------

"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl:
I have looked and searched. What good is the databind property on
Radiobuttons? How does one go about actually using it? What is a good
resource on this? I understand that I can easily get/set the information I
need programmatically, but what about the databind property I just don't

understand it's value.



Rourke Eleven
Cthulhu saves sinners - in case he's hungry later!


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004

Nov 20 '05 #7
No of course you would not have a single Radio button on a form, however, I
personally have used bound radio buttons on a form along with other
controls. I wrote a helpdesk system and some of the selections were bound to
Radio buttons and checkboxes.

It's also possible to display checkboxes on a datagrid bound in the same way
with a bit of binding magic and a dice of Controls. But that gets a little
complex.

In asnwer to you question ( and im not Microsoft ) ; why not ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ken's answer is great and I think I will use it, but it still doesn't answer 1 of my questions. Why have databinding on Radiobuttons? What is its use?
I can't think of a time that I would have just a single radiobutton on a
form. As the Article that Ken sent points out Microsoft needs to think
about building in a control that does what Duncan Mackenzie does in his user control. Make a Radiobutton ListControl with a simple interface like that
of a Web Combobox which you can input your own Members with a Text/values in a listcontrol container or you can databind.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:eH**************@TK2MSFTNGP10.phx.gbl...
OK, that was not clear in your OP. Ken posted link but I have not checked
that out, if you are still having difficulties by tomorrow, I'll try and
help

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
For all others this is regarding VB.Net Windows Forms not ASP.Net

Terry,

Ok I understand that but what about in the the context of a group of
Radiobuttons and using mutual exclusivity.

For example I have field in a database that I want to have the values of
0,
1, 2 or 3 (or actually any values I want to Assign)

So Radiobutton 1 sets the value to 0 and so on.

How does databinding work in this instance?

Or even if I had a field in a database that was bool and I wanted to
use Radiobuttons instead of a Checkbox.

I would love to be able to set all of this with properties instead of
programmatically with a decision stucture and then binding.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
> OK, to illustrate. Create an access database with two fields in it. A ID
(
> PK ) field and a Yes/No field called 'Data'. Add Three records

with the
> centre on unchecked.
>
> Using server explorer, drag the table to the form and create a DataSet > DS(DS1) using the wizard.
>
> Drag a Checkbox onto your form (cb1) and a button (btnUP), put the
following
> code in and run it. You will see by clicking the button once the CB
> disapears and then once again, it appears. You have bound the Data

to the
> control and are using the binding context of the form to move
through the
> bound records.
>
> Voilla !!
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> DA.Fill(Ds1)
> CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
> End Sub
>
> Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e

As > System.EventArgs) Handles btnUP.Click
> Dim bm As BindingManagerBase
> bm = Me.BindingContext.Item(Ds1.Tables(0))
> bm.Position += 1
> End Sub
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
>
> "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> news:uY**************@TK2MSFTNGP10.phx.gbl...
> > I have looked and searched. What good is the databind property on
> > Radiobuttons? How does one go about actually using it? What is a

good
> > resource on this? I understand that I can easily get/set the
information
> I
> > need programmatically, but what about the databind property I just

don't
> > understand it's value.
> >
> >
> >
> >
> >
> >
> >
> > Rourke Eleven
> > Cthulhu saves sinners - in case he's hungry later!
> >
> >
>
>



Nov 20 '05 #8
I am not just trying to argue, but what would you bind to the radiobutton?
The Text property? Help me here I am a little lost. Normally I would want
to bind data so that I could effect a change to the backend data or display
the data.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:OY**************@TK2MSFTNGP12.phx.gbl...
No of course you would not have a single Radio button on a form, however, I personally have used bound radio buttons on a form along with other
controls. I wrote a helpdesk system and some of the selections were bound to Radio buttons and checkboxes.

It's also possible to display checkboxes on a datagrid bound in the same way with a bit of binding magic and a dice of Controls. But that gets a little
complex.

In asnwer to you question ( and im not Microsoft ) ; why not ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ken's answer is great and I think I will use it, but it still doesn't answer
1 of my questions. Why have databinding on Radiobuttons? What is its

use?

I can't think of a time that I would have just a single radiobutton on a
form. As the Article that Ken sent points out Microsoft needs to think
about building in a control that does what Duncan Mackenzie does in his

user
control. Make a Radiobutton ListControl with a simple interface like that
of a Web Combobox which you can input your own Members with a

Text/values in
a listcontrol container or you can databind.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
OK, that was not clear in your OP. Ken posted link but I have not

checked that out, if you are still having difficulties by tomorrow, I'll try and help

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> For all others this is regarding VB.Net Windows Forms not ASP.Net
>
> Terry,
>
> Ok I understand that but what about in the the context of a group of
> Radiobuttons and using mutual exclusivity.
>
> For example I have field in a database that I want to have the values of
0,
> 1, 2 or 3 (or actually any values I want to Assign)
>
> So Radiobutton 1 sets the value to 0 and so on.
>
> How does databinding work in this instance?
>
> Or even if I had a field in a database that was bool and I wanted to use > Radiobuttons instead of a Checkbox.
>
> I would love to be able to set all of this with properties instead
of > programmatically with a decision stucture and then binding.
>
>
> "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
> news:Ok**************@TK2MSFTNGP12.phx.gbl...
> > OK, to illustrate. Create an access database with two fields in it.
A
ID
(
> > PK ) field and a Yes/No field called 'Data'. Add Three records

with the
> > centre on unchecked.
> >
> > Using server explorer, drag the table to the form and create a

DataSet
> > DS(DS1) using the wizard.
> >
> > Drag a Checkbox onto your form (cb1) and a button (btnUP), put the
> following
> > code in and run it. You will see by clicking the button once the
CB > > disapears and then once again, it appears. You have bound the Data

to the
> > control and are using the binding context of the form to move through the
> > bound records.
> >
> > Voilla !!
> >
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load
> > DA.Fill(Ds1)
> > CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
> > End Sub
> >
> > Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles btnUP.Click
> > Dim bm As BindingManagerBase
> > bm = Me.BindingContext.Item(Ds1.Tables(0))
> > bm.Position += 1
> > End Sub
> >
> > --
> >
> > OHM ( Terry Burns )
> > . . . One-Handed-Man . . .
> >
> >
> > "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> > news:uY**************@TK2MSFTNGP10.phx.gbl...
> > > I have looked and searched. What good is the databind property on > > > Radiobuttons? How does one go about actually using it? What is a good
> > > resource on this? I understand that I can easily get/set the
> information
> > I
> > > need programmatically, but what about the databind property I just don't
> > > understand it's value.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Rourke Eleven
> > > Cthulhu saves sinners - in case he's hungry later!
> > >
> > >
> >
> >
>
>



Nov 20 '05 #9
Well, in my first reply I showed you how to bind a checkbox to a field in a
database. Is this not a valid use ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
I am not just trying to argue, but what would you bind to the radiobutton?
The Text property? Help me here I am a little lost. Normally I would want to bind data so that I could effect a change to the backend data or display the data.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:OY**************@TK2MSFTNGP12.phx.gbl...
No of course you would not have a single Radio button on a form, however,
I
personally have used bound radio buttons on a form along with other
controls. I wrote a helpdesk system and some of the selections were bound
to
Radio buttons and checkboxes.

It's also possible to display checkboxes on a datagrid bound in the same way
with a bit of binding magic and a dice of Controls. But that gets a

little complex.

In asnwer to you question ( and im not Microsoft ) ; why not ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ken's answer is great and I think I will use it, but it still doesn't

answer
1 of my questions. Why have databinding on Radiobuttons? What is its

use?

I can't think of a time that I would have just a single radiobutton on a form. As the Article that Ken sent points out Microsoft needs to think about building in a control that does what Duncan Mackenzie does in his
user
control. Make a Radiobutton ListControl with a simple interface like that of a Web Combobox which you can input your own Members with a Text/values
in
a listcontrol container or you can databind.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:eH**************@TK2MSFTNGP10.phx.gbl...
> OK, that was not clear in your OP. Ken posted link but I have not

checked
> that out, if you are still having difficulties by tomorrow, I'll try

and > help
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
>
> "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> > For all others this is regarding VB.Net Windows Forms not ASP.Net
> >
> > Terry,
> >
> > Ok I understand that but what about in the the context of a group
of > > Radiobuttons and using mutual exclusivity.
> >
> > For example I have field in a database that I want to have the

values
of
> 0,
> > 1, 2 or 3 (or actually any values I want to Assign)
> >
> > So Radiobutton 1 sets the value to 0 and so on.
> >
> > How does databinding work in this instance?
> >
> > Or even if I had a field in a database that was bool and I wanted to use
> > Radiobuttons instead of a Checkbox.
> >
> > I would love to be able to set all of this with properties instead of > > programmatically with a decision stucture and then binding.
> >
> >
> > "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote
in > message
> > news:Ok**************@TK2MSFTNGP12.phx.gbl...
> > > OK, to illustrate. Create an access database with two fields in

it.
A
ID
> (
> > > PK ) field and a Yes/No field called 'Data'. Add Three records

with
> the
> > > centre on unchecked.
> > >
> > > Using server explorer, drag the table to the form and create a
DataSet
> > > DS(DS1) using the wizard.
> > >
> > > Drag a Checkbox onto your form (cb1) and a button (btnUP), put the > > following
> > > code in and run it. You will see by clicking the button once the

CB > > > disapears and then once again, it appears. You have bound the
Data to
> the
> > > control and are using the binding context of the form to move

through
> the
> > > bound records.
> > >
> > > Voilla !!
> > >
> > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal
e As > > > System.EventArgs) Handles MyBase.Load
> > > DA.Fill(Ds1)
> > > CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
> > > End Sub
> > >
> > > Private Sub btnUP_Click(ByVal sender As System.Object, ByVal
e As
> > > System.EventArgs) Handles btnUP.Click
> > > Dim bm As BindingManagerBase
> > > bm = Me.BindingContext.Item(Ds1.Tables(0))
> > > bm.Position += 1
> > > End Sub
> > >
> > > --
> > >
> > > OHM ( Terry Burns )
> > > . . . One-Handed-Man . . .
> > >
> > >
> > > "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> > > news:uY**************@TK2MSFTNGP10.phx.gbl...
> > > > I have looked and searched. What good is the databind
property on > > > > Radiobuttons? How does one go about actually using it? What
is
a > good
> > > > resource on this? I understand that I can easily get/set the
> > information
> > > I
> > > > need programmatically, but what about the databind property I just > don't
> > > > understand it's value.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Rourke Eleven
> > > > Cthulhu saves sinners - in case he's hungry later!
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #10
Here we have an Class Person. Within it we declare a public event called
CheckedChanged, this is made up of the property which the binding manager
listens for an event for once binding has been set. When the Property
changes from checked to unchecked we call a helper function which raises
this event and the binding manager syncs the control ( rad1 ) to this
property.

Button1.click changes the property of the aPerson object to checked, this is
then reflected through the bindings in the rad1 state.

On_Load is where we set the bindings

HTH

Private WithEvents aPerson As New Person

Public Class Person

Public Event CheckedChanged As EventHandler

Private m_checked As Boolean

Public Sub New()
m_checked = False
End Sub

Public Property Checked() As Boolean
Get
Return m_checked
End Get
Set(ByVal value As Boolean)
m_checked = value
PropertyChanged(EventArgs.Empty)
End Set
End Property

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
rad1.DataBindings.Add("Checked", aPerson, "Checked")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
aPerson.checked = True
End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
I am not just trying to argue, but what would you bind to the radiobutton?
The Text property? Help me here I am a little lost. Normally I would want to bind data so that I could effect a change to the backend data or display the data.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:OY**************@TK2MSFTNGP12.phx.gbl...
No of course you would not have a single Radio button on a form, however,
I
personally have used bound radio buttons on a form along with other
controls. I wrote a helpdesk system and some of the selections were bound
to
Radio buttons and checkboxes.

It's also possible to display checkboxes on a datagrid bound in the same way
with a bit of binding magic and a dice of Controls. But that gets a

little complex.

In asnwer to you question ( and im not Microsoft ) ; why not ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ken's answer is great and I think I will use it, but it still doesn't

answer
1 of my questions. Why have databinding on Radiobuttons? What is its

use?

I can't think of a time that I would have just a single radiobutton on a form. As the Article that Ken sent points out Microsoft needs to think about building in a control that does what Duncan Mackenzie does in his
user
control. Make a Radiobutton ListControl with a simple interface like that of a Web Combobox which you can input your own Members with a Text/values
in
a listcontrol container or you can databind.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:eH**************@TK2MSFTNGP10.phx.gbl...
> OK, that was not clear in your OP. Ken posted link but I have not

checked
> that out, if you are still having difficulties by tomorrow, I'll try

and > help
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
>
> "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> > For all others this is regarding VB.Net Windows Forms not ASP.Net
> >
> > Terry,
> >
> > Ok I understand that but what about in the the context of a group
of > > Radiobuttons and using mutual exclusivity.
> >
> > For example I have field in a database that I want to have the

values
of
> 0,
> > 1, 2 or 3 (or actually any values I want to Assign)
> >
> > So Radiobutton 1 sets the value to 0 and so on.
> >
> > How does databinding work in this instance?
> >
> > Or even if I had a field in a database that was bool and I wanted to use
> > Radiobuttons instead of a Checkbox.
> >
> > I would love to be able to set all of this with properties instead of > > programmatically with a decision stucture and then binding.
> >
> >
> > "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote
in > message
> > news:Ok**************@TK2MSFTNGP12.phx.gbl...
> > > OK, to illustrate. Create an access database with two fields in

it.
A
ID
> (
> > > PK ) field and a Yes/No field called 'Data'. Add Three records

with
> the
> > > centre on unchecked.
> > >
> > > Using server explorer, drag the table to the form and create a
DataSet
> > > DS(DS1) using the wizard.
> > >
> > > Drag a Checkbox onto your form (cb1) and a button (btnUP), put the > > following
> > > code in and run it. You will see by clicking the button once the

CB > > > disapears and then once again, it appears. You have bound the
Data to
> the
> > > control and are using the binding context of the form to move

through
> the
> > > bound records.
> > >
> > > Voilla !!
> > >
> > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal
e As > > > System.EventArgs) Handles MyBase.Load
> > > DA.Fill(Ds1)
> > > CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
> > > End Sub
> > >
> > > Private Sub btnUP_Click(ByVal sender As System.Object, ByVal
e As
> > > System.EventArgs) Handles btnUP.Click
> > > Dim bm As BindingManagerBase
> > > bm = Me.BindingContext.Item(Ds1.Tables(0))
> > > bm.Position += 1
> > > End Sub
> > >
> > > --
> > >
> > > OHM ( Terry Burns )
> > > . . . One-Handed-Man . . .
> > >
> > >
> > > "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> > > news:uY**************@TK2MSFTNGP10.phx.gbl...
> > > > I have looked and searched. What good is the databind
property on > > > > Radiobuttons? How does one go about actually using it? What
is
a > good
> > > > resource on this? I understand that I can easily get/set the
> > information
> > > I
> > > > need programmatically, but what about the databind property I just > don't
> > > > understand it's value.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Rourke Eleven
> > > > Cthulhu saves sinners - in case he's hungry later!
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #11
I forgot to include the forms class level declaration of the aPerson

Private WithEvents aPerson As New Person

Cheers
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Here we have an Class Person. Within it we declare a public event called
CheckedChanged, this is made up of the property which the binding manager
listens for an event for once binding has been set. When the Property
changes from checked to unchecked we call a helper function which raises
this event and the binding manager syncs the control ( rad1 ) to this
property.

Button1.click changes the property of the aPerson object to checked, this is then reflected through the bindings in the rad1 state.

On_Load is where we set the bindings

HTH

Private WithEvents aPerson As New Person

Public Class Person

Public Event CheckedChanged As EventHandler

Private m_checked As Boolean

Public Sub New()
m_checked = False
End Sub

Public Property Checked() As Boolean
Get
Return m_checked
End Get
Set(ByVal value As Boolean)
m_checked = value
PropertyChanged(EventArgs.Empty)
End Set
End Property

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
rad1.DataBindings.Add("Checked", aPerson, "Checked")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
aPerson.checked = True
End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
I am not just trying to argue, but what would you bind to the radiobutton?
The Text property? Help me here I am a little lost. Normally I would want
to bind data so that I could effect a change to the backend data or

display
the data.

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:OY**************@TK2MSFTNGP12.phx.gbl...
No of course you would not have a single Radio button on a form, however,
I
personally have used bound radio buttons on a form along with other
controls. I wrote a helpdesk system and some of the selections were

bound
to
Radio buttons and checkboxes.

It's also possible to display checkboxes on a datagrid bound in the same way
with a bit of binding magic and a dice of Controls. But that gets a little complex.

In asnwer to you question ( and im not Microsoft ) ; why not ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Rourke Eleven" <Ro******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> Ken's answer is great and I think I will use it, but it still
doesn't answer
> 1 of my questions. Why have databinding on Radiobuttons? What is its use?
>
> I can't think of a time that I would have just a single radiobutton on a > form. As the Article that Ken sent points out Microsoft needs to think > about building in a control that does what Duncan Mackenzie does in his user
> control. Make a Radiobutton ListControl with a simple interface
like that
> of a Web Combobox which you can input your own Members with a Text/values
in
> a listcontrol container or you can databind.
>
> "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message
> news:eH**************@TK2MSFTNGP10.phx.gbl...
> > OK, that was not clear in your OP. Ken posted link but I have not
checked
> > that out, if you are still having difficulties by tomorrow, I'll
try and
> > help
> >
> > --
> >
> > OHM ( Terry Burns )
> > . . . One-Handed-Man . . .
> >
> >
> > "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> > news:%2****************@tk2msftngp13.phx.gbl...
> > > For all others this is regarding VB.Net Windows Forms not
ASP.Net > > >
> > > Terry,
> > >
> > > Ok I understand that but what about in the the context of a group of > > > Radiobuttons and using mutual exclusivity.
> > >
> > > For example I have field in a database that I want to have the values
of
> > 0,
> > > 1, 2 or 3 (or actually any values I want to Assign)
> > >
> > > So Radiobutton 1 sets the value to 0 and so on.
> > >
> > > How does databinding work in this instance?
> > >
> > > Or even if I had a field in a database that was bool and I
wanted to use
> > > Radiobuttons instead of a Checkbox.
> > >
> > > I would love to be able to set all of this with properties
instead of
> > > programmatically with a decision stucture and then binding.
> > >
> > >
> > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com>
wrote
in > > message
> > > news:Ok**************@TK2MSFTNGP12.phx.gbl...
> > > > OK, to illustrate. Create an access database with two fields
in it.
A
> ID
> > (
> > > > PK ) field and a Yes/No field called 'Data'. Add Three
records with
> > the
> > > > centre on unchecked.
> > > >
> > > > Using server explorer, drag the table to the form and create a > DataSet
> > > > DS(DS1) using the wizard.
> > > >
> > > > Drag a Checkbox onto your form (cb1) and a button (btnUP), put
the > > > following
> > > > code in and run it. You will see by clicking the button once the CB
> > > > disapears and then once again, it appears. You have bound the Data to
> > the
> > > > control and are using the binding context of the form to move
through
> > the
> > > > bound records.
> > > >
> > > > Voilla !!
> > > >
> > > > Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e
As
> > > > System.EventArgs) Handles MyBase.Load
> > > > DA.Fill(Ds1)
> > > > CB1.DataBindings.Add("Checked", Ds1.Tables(0), "Data")
> > > > End Sub
> > > >
> > > > Private Sub btnUP_Click(ByVal sender As System.Object,
ByVal
e As
> > > > System.EventArgs) Handles btnUP.Click
> > > > Dim bm As BindingManagerBase
> > > > bm = Me.BindingContext.Item(Ds1.Tables(0))
> > > > bm.Position += 1
> > > > End Sub
> > > >
> > > > --
> > > >
> > > > OHM ( Terry Burns )
> > > > . . . One-Handed-Man . . .
> > > >
> > > >
> > > > "Rourke Eleven" <Ro******@hotmail.com> wrote in message
> > > > news:uY**************@TK2MSFTNGP10.phx.gbl...
> > > > > I have looked and searched. What good is the databind
property
on
> > > > > Radiobuttons? How does one go about actually using it?

What is
a
> > good
> > > > > resource on this? I understand that I can easily get/set

the > > > information
> > > > I
> > > > > need programmatically, but what about the databind property

I just
> > don't
> > > > > understand it's value.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Rourke Eleven
> > > > > Cthulhu saves sinners - in case he's hungry later!
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #12

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

Similar topics

1
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML:...
3
by: Martien van Wanrooij | last post by:
I am working on a site with some pages that all have a form that starts with a group of radiobuttons. By default none of the buttons is checked. Before submitting the form there is a validation...
1
by: --=|3s|=-- | last post by:
Hi, I'm trying to create a form in VISUAL BASIC .NET wich shows values of records from a customers table. For example a form wich shows the name, surname and sex of a person. For the name &...
2
by: Chris Ashley | last post by:
I have a couple of RadioButtons both with the same GroupName. Is there any way I can use a RequiredFieldValidator to ensure that at least one of the RadioButtons in the group is selected? Setting...
4
by: news.microsoft.com | last post by:
Hello, I have two databound radiobuttons which have advanced databinding properties of onpropertychanged enabled so that I can raise the columnchanged event whenever the radiobuttons are...
0
by: PaulS | last post by:
Hello! I put on Form PictureBox and I set big image. Next I put many radiobuttons (80) on PictureBox, but I have problem. I want that 10 radiobuttons have own Checked, next part of 10...
4
by: PedroVision | last post by:
I have a VB 2005 form with 140 different radiobuttons... Some are "checked", some are not... I want to reset all radiobuttons to "unchecked". I've been searching and trying differnet...
8
by: =?Utf-8?B?UmljaA==?= | last post by:
If you enclose a group of radiobuttons (option buttons in MS Access) in an option group control (a frame control) in Access -- the frame control will return the index of the option button that is...
0
by: | last post by:
I am using radiobuttons in a gridview, and not a column of radiobuttons. I have one cell in each row with several radiobuttons that the user has to choose a radiobutton within each row. How can I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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...
0
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,...

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.