winforms - how to check the radio button is checked or not in windows form -
I have 3 pairs of radios in my form, I want to see every group of Radiobutton once to see a radiobutan. When the user press the Save button. I used the code below to check every radio button, but I think this is a better way to check.
if (radioBttnAddrssCoYes.Checked || rdoBttnAddCorrectNo.Checked) {if (rdoGroundFloorTrue.Checked || radioGroundFFalse.Checked) {if (rdoHomeTrue.Checked || radioMeet.Checked) {// Here I Do something} second {message box} Show ("Please see customer all day at home"); }} And {message box}. Show ("Please check ground floor delivery"); }} Else {MessageBox.Show ("check the address correct"); }
Thank you for your support and support
I probably would have to separate this bit, but this' T means your way is wrong.
if (velated radiogram IIS checked (radio BTN adsource, RWBTNEdactors, not, "check address correct") & amp; amp; amp; amp; amp; amp; amp; amp; amp;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;; r;; Check Flow Delivery ") & amp;; & VaildateRadioGroupIsChecked VaildateRadioGroupIsChecked (RadioButton A, RadioButton B, String MessageToUser) {If bool (rdoHomeTrue, radioMeet," Check customer all day at home ")) {// Your work In doing ...} private (a.checked! & Amp; B; checked in B.) {Messagebox.Show (Mess ageToUser); return false; } Back true; } Of course, you can develop it further and can not send 2 radio buttons to the function, but this element is in this way, if you have 3, 4, or N radio buttons You can see them in a simple call.
To verify another well-known technique that a radio box is checked, just a variable at the boolean form level that is false by default, and when any radio button If checked, then correct is changed. However, with this technique you will not be able to serve well in this case, because you will need 3 bullion variables for this, and the code will not be complicated compared to other solutions.
To answer your question in the comment, I will probably do something like this: string message source = VaildateRadioGroupIsChecked (radioBttnAddrssCoYes, rdoBttnAddCorrectNo, "check correct address") + VaildateRadioGroupIsChecked (rdoGroundFloorTrue, radioGroundFFalse, "Please check Ground floor delivery") + VaildateRadioGroupIsChecked (rdoHomeTrue, RadioMeet, "Please check customer at home all day"); If (MessageToUser.Length == 0) {// your stuff} and {messagebox. Show (MessageToUser); } Private string VaildateRadioGroupIsChecked (RadioButton A, RadioButton B, String MessageToUser) {if (a.Checked & amp;! Amp;; B.Checked) {Return MessageToUser + "\ n"; } Return string Empty; }
Comments
Post a Comment