.net - C#: Simple question regarding radio and checkbox controls. Getting the wrong return type? -


getting error of :

error   1   'string radiogrouptester.form1.chkreceipt_checkedchanged(object, system.eventargs)' has wrong return type 

when compile simple program understand radio , check box controls.

here's code form follows:

    private string rdomastercard_checkedchanged(object sender, eventargs e)     {         if (rdomastercard.checked)             return "you have selected mastercard";         else             return "you have selected visa";     }      private string chkreceipt_checkedchanged(object sender, eventargs e)     {         if (chkreceipt.checked)             return "you receive receipt";         else             return "you not receive receipt";     }      private string chkrecurring_checkedchanged(object sender, eventargs e)     {         if (chkrecurring.checked)         {             return "you charged monthly";         }         else             return "this 1 time payment";     } 

and here's form looks like:

enter image description here

what doing wrong here? apologize, i'm still pretty new c# , vs 2010.

thanks, ray

you can't return things event handler. mean show message box instead? or give feedback through label? like:

private string void rdomastercard_checkedchanged(object sender, eventargs e) {     if (rdomastercard.checked)         return messagebox.show("you have selected mastercard");     else         return messagebox.show("you have selected visa"); }

and same other examples. example uses message box can set label's text or whatever.

the reason? how expect c# know want when you're returning event handler? event handler handles events, nothing more.

edit: want do, like:

private void btnconfirmchoices_click(object sender, eventargs e) {     string str = string.empty;      if(rdomastercard.checked)         str += "you have selected mastercard\n";     else         str += "you have selected visa\n";      if (chkreceipt.checked)         str += "you receive receipt\n";     else         str += "you not receive receipt\n";      if (chkrecurring.checked)         str += "you charged monthly";     else         str += "this 1 time payment";      messagebox.show(str); } 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -