467,907 Members | 1,613 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

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
  • viewed: 4184
Share:
11 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Martien van Wanrooij | last post: by
1 post views Thread by --=|3s|=-- | last post: by
2 posts views Thread by Chris Ashley | last post: by
4 posts views Thread by news.microsoft.com | last post: by
reply views Thread by PaulS | last post: by
reply views Thread by | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.