Solved

Radio Button "yes/no" Binding WinForms

Posted on 2013-01-07
2
597 Views
Last Modified: 2013-01-07
I am new to radio button binding.  I have the following controls on my form:
gbWeldFixPic - Group Box Control
rbWeldFixPicNo - Radio Button Control - in gbWeldFixPic
rbWeldFixPicYes - Radio Button Control - in gbWeldFixPic

I have a field in sql that stored the value as a bit (field name:  engord.weldfixpic)

When I open the form for an existing order.... if my bit value is 1 then I want the rbWeldFixPicYes = checked, if my bit value is 0 then I want the rbWeldFixPicNo = checked.

What is a good way to implement this?  Please provide a working code example.
0
Comment
Question by:ndornack
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38750830
do it explicitly would be the easiest and fastest way to achieve what u want.
simply check the value of engord.weldfixpic, something like:

UpdateWeldFixPic(bool.Parse(engord.weldfixpic.ToString());

UpdateWeldFixPic(bool isWeldFixPic){
rbWeldFixPicYes.Checked = isWeldFixPic;
rbWeldFixPicNo.Checked = !isWeldFixPic;
}

Open in new window

0
 

Author Closing Comment

by:ndornack
ID: 38751621
I figured out a different way to do it, going along your thoughts though:

        private void rbWeldFixPicYes_CheckedChanged(object sender, EventArgs e)
        {
            if (rbWeldFixPicYes.Checked == true)
                newEngOrd.WeldFixPic = true;
            else
                newEngOrd.WeldFixPic = false;
        }

Thanks for your help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now