473,322 Members | 1,806 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,322 software developers and data experts.

Databound Radiobuttons

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 changed.

In the columnchanged event I am simply accepting changes into the dataset.
There is no dataadapter because it is a standalone dataset.

When one radiobutton is already checked (as opposed to neither) and I select
the non-checked radiobutton, the columnchanged event is raised twice and
erases the checked value of both radiobuttons in the acceptchanges call. It
is raised twice because it is first raised to un-check the first radio
button, and then called again to check the second radio button... but on the
second call it somehow sees that the second radio button is not physically
checked yet, so sends a false value.

This is pretty simple to reproduce and funnily enough nothing seems to be
available on the net to explain this with radiobuttons.
Troy
Mar 7 '06 #1
4 2078
Probably to explain a little better:

You have Radiobutton #1 and Radiobutton #2.

If #1 is checked and you click #2, firstly the two radiobuttons physically
swap the checked status and are visibly correct. Then the columnchanged
event is raised for the dataset. The event is firstly handled for #1 and
acceptchanges is called... this causes the new false value for #1 to be
saved, *and* for the existing false value for #2 (still false on the
datarow), triggering the stored value and the checked value for #2 to be
changed to false. This triggers the columnchanged event again and simply
places false values into the radiobutton databound columns with
acceptchanges.

Is there any way to break that cycle?
Troy
"news.microsoft.com" <tr**@NO-SPAMebswift.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 changed.

In the columnchanged event I am simply accepting changes into the dataset.
There is no dataadapter because it is a standalone dataset.

When one radiobutton is already checked (as opposed to neither) and I
select the non-checked radiobutton, the columnchanged event is raised
twice and erases the checked value of both radiobuttons in the
acceptchanges call. It is raised twice because it is first raised to
un-check the first radio button, and then called again to check the second
radio button... but on the second call it somehow sees that the second
radio button is not physically checked yet, so sends a false value.

This is pretty simple to reproduce and funnily enough nothing seems to be
available on the net to explain this with radiobuttons.
Troy

Mar 7 '06 #2
Hi,

http://msdn.microsoft.com/msdnmag/is...dvancedBasics/

Ken
-------------
"news.microsoft.com" <tr**@NO-SPAMebswift.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 changed.

In the columnchanged event I am simply accepting changes into the dataset.
There is no dataadapter because it is a standalone dataset.

When one radiobutton is already checked (as opposed to neither) and I
select the non-checked radiobutton, the columnchanged event is raised
twice and erases the checked value of both radiobuttons in the
acceptchanges call. It is raised twice because it is first raised to
un-check the first radio button, and then called again to check the second
radio button... but on the second call it somehow sees that the second
radio button is not physically checked yet, so sends a false value.

This is pretty simple to reproduce and funnily enough nothing seems to be
available on the net to explain this with radiobuttons.
Troy

Mar 7 '06 #3
Thanks Ken, just curious if there is a known workaround without using a
custom control? I've got separate columns in the dataset for each
radiobutton... rather than the scenario of one column and separate values
for each radiobutton; it's a matter of semantics really, especially when
only dealing with only a couple of paired groups of radiobuttons.

I wanted to try and keep the solution simple and have no control-initiated
events to update the dataset outside of the databindings setting. I have
seen the custom control solution before, but I'm thinking that there has to
be a far simpler answer.

I think the biggest hurdle is getting around the dataset's acceptchanges
overriding the newly checked radiobutton with the old dataset contents,
sparking the change to be lost.
Troy
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
Hi,

http://msdn.microsoft.com/msdnmag/is...dvancedBasics/

Ken
-------------
"news.microsoft.com" <tr**@NO-SPAMebswift.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 changed.

In the columnchanged event I am simply accepting changes into the
dataset. There is no dataadapter because it is a standalone dataset.

When one radiobutton is already checked (as opposed to neither) and I
select the non-checked radiobutton, the columnchanged event is raised
twice and erases the checked value of both radiobuttons in the
acceptchanges call. It is raised twice because it is first raised to
un-check the first radio button, and then called again to check the
second radio button... but on the second call it somehow sees that the
second radio button is not physically checked yet, so sends a false
value.

This is pretty simple to reproduce and funnily enough nothing seems to be
available on the net to explain this with radiobuttons.
Troy


Mar 8 '06 #4
I figured out a simple hack. At this stage I think it will only work with a
two radiobutton group.

Here's the hack:

Create the two radiobutton group and databind them to two separate table
values. Setup the databindings checked event for each radiobutton, and
under advanced, change the event type to onpropertychanged. If you run the
project now, you will see the problem reproduced, where it actually takes
two clicks to change to a new radiobutton value. To fix this, in ONE of the
radiobutton column definitions, change the expression to 'Not
otherradiocolumn', where otherradiocolumn is the name of the table column
for the OTHER radiobutton. This will ensure that the radiobuttons always
switch and never cancel one another out.

If this solution could be expanded to three or more radiobuttons it would
remove the need for messy usercontrols, though I'm not sure it would be
possible.
Troy

"news.microsoft.com" <tr**@NO-SPAMebswift.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 changed.

In the columnchanged event I am simply accepting changes into the dataset.
There is no dataadapter because it is a standalone dataset.

When one radiobutton is already checked (as opposed to neither) and I
select the non-checked radiobutton, the columnchanged event is raised
twice and erases the checked value of both radiobuttons in the
acceptchanges call. It is raised twice because it is first raised to
un-check the first radio button, and then called again to check the second
radio button... but on the second call it somehow sees that the second
radio button is not physically checked yet, so sends a false value.

This is pretty simple to reproduce and funnily enough nothing seems to be
available on the net to explain this with radiobuttons.
Troy

Apr 3 '06 #5

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 &...
11
by: Rourke Eleven | last post by:
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...
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...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.