PC Review


Reply
Thread Tools Rate Thread

DataBinding a RadioButton group

 
 
Srikanth
Guest
Posts: n/a
 
      19th Aug 2003
Hi,
I have two RadioButtons in a GroupBox. I want to databind these
radiobuttons with a value (if '0', one radiobutton is checked else another)
of a column in a DataTable.

Iam not able to figure out how to do this. Please someone help me.

Regards,
Srikanth.


 
Reply With Quote
 
 
 
 
Scot Rose [MSFT]
Guest
Posts: n/a
 
      19th Aug 2003
You cannot. Think about this... If I bind oth radio buttons to the same field and assuming the value is true BOTH of the controls cannot be true

RadioButton1.DataBindings.Add("Checked", ds, "Cust.Contract")
RadioButton2.DataBindings.Add("Checked", ds, "Cust.Contract")

then what is going to happen is that Radio button 2 is going to be set to the true value and clear 1 even though 1 should also be true.

What you need to do is bind another control (Like a Textbox) then trap the Change events and set the Radio buttons accordingly, and trap the Radio button events to set the value
of the text box that is bound.

Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com

Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (E-Mail Removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.




--------------------
>From: "Srikanth" <(E-Mail Removed)>
>Subject: DataBinding a RadioButton group
>Date: Tue, 19 Aug 2003 15:49:19 +1000
>Lines: 11
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <#(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.windowsforms
>NNTP-Posting-Host: 65-58.dsl.connexus.net.au 203.222.65.58
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.windowsforms:50510
>X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
>
>Hi,
> I have two RadioButtons in a GroupBox. I want to databind these
>radiobuttons with a value (if '0', one radiobutton is checked else another)
>of a column in a DataTable.
>
>Iam not able to figure out how to do this. Please someone help me.
>
>Regards,
>Srikanth.
>
>
>



 
Reply With Quote
 
Brian P. Hammer
Guest
Posts: n/a
 
      19th Aug 2003
Scott has the correct answer. I have several on my form. In each case, I
set the value of a textbox and that textbox is bound to my data.

On the opening of the form I set the values of the checkboxes.

If Not HasLoaded Then Exit Sub
If Me.txtLoanLease.Text = "Loan" Then
Me.chkLoan.Checked = True
Me.chkLease.Checked = False
ElseIf Me.txtLoanLease.Text = "Lease" Then
Me.chkLoan.Checked = False
Me.chkLease.Checked = True
End If


--
BRIAN HAMMER
"Srikanth" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
> I have two RadioButtons in a GroupBox. I want to databind these
> radiobuttons with a value (if '0', one radiobutton is checked else

another)
> of a column in a DataTable.
>
> Iam not able to figure out how to do this. Please someone help me.
>
> Regards,
> Srikanth.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RadioButton DataBinding problem ulrich schumacher Microsoft Dot NET Framework Forms 0 23rd Apr 2008 06:01 PM
radiobutton group rodchar Microsoft ASP .NET 0 11th Feb 2008 04:59 PM
DataBinding radioButton toma Microsoft C# .NET 0 24th Nov 2004 10:25 PM
Radiobutton and Databinding to a Dataset Dandy Microsoft Dot NET Compact Framework 0 3rd Aug 2004 12:33 PM
Radiobutton databinding: Babu Mannaravalappil Microsoft Dot NET Framework Forms 2 27th Feb 2004 03:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 PM.