Solved

Radio Button "yes/no" Binding WinForms

Posted on 2013-01-07
2
626 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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