Home > Mobile >  WinForms : adding a form1 object as a parameter of radiobutton event causes error in the Designer
WinForms : adding a form1 object as a parameter of radiobutton event causes error in the Designer

Time:12-04

Here are the code snippeds, form1.cs: enter image description here

And, here is the Designer error: enter image description here

If I pass a form object as a parameter into a normal method argument, it works fine this way, no designer & eventhandler error occurs.

However if I use events like RadioButton Checked Changed, then I get this EVENT HANDLER & DESIGNER error.

How do I fix it? I want to use form objects and their events together at the same time here, but there is an error.

CodePudding user response:

Yes, the error is expected. because CheckedChanged declaration is like this

private void radioButton1_CheckedChanged(Object sender, 
                                         EventArgs e)

You cannot pass the parameter to it.

and as @Klaus Gütter mentioned in the comment you can use this if in the same form otherwise, you can create a property for another form and use it if you are in different form.

  • Related