Solved

Radio Button "yes/no" Binding WinForms

Posted on 2013-01-07
2
604 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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