PDA

View Full Version : سوال: ایجاد " یک " رویداد CheckedChanged برای چند RadioButton



parsa lotfy
یک شنبه 23 اسفند 1394, 11:46 صبح
با سلام...

دوستان برنامه ای دارم ، در اون چند RadioButton هستش به دو GroupBox دسته بندی شده اند...

وقتی بر روی radiobutton های گروه اول کلیک میکنم تا رویداد checkedchanged مربوط به اون رو بیارم برای تمام radio button ها یک متد رو میاره ، یعنی رویداد checkedchanged تمام radiobutton ها

یک متد ثابت هستش ، برای گروه اول یک متد ، و برای اون یکی گروه یک متد دیگر ...

میخواستم بدونم چیجوری میشه این کارو کرد ؟؟؟

139580

رویداد group box اول :

// change Buttons based on option chosen by sender
private void buttonType_CheckedChanged(
object sender, EventArgs e )
{
if ( sender == okRadioButton ) // display OK Button
buttonType = MessageBoxButtons.OK;

// display OK and Cancel Buttons
else if ( sender == okCancelRadioButton )
buttonType = MessageBoxButtons.OKCancel;

// display Abort, Retry and Ignore Buttons
else if ( sender == abortRetryIgnoreRadioButton )
buttonType = MessageBoxButtons.AbortRetryIgnore;

// display Yes, No and Cancel Buttons
else if ( sender == yesNoCancelRadioButton )
buttonType = MessageBoxButtons.YesNoCancel;

// display Yes and No Buttons
else if ( sender == yesNoRadioButton )
buttonType = MessageBoxButtons.YesNo;

// only one option left--display Retry and Cancel Buttons
else
buttonType = MessageBoxButtons.RetryCancel;
} // end method buttonType_Changed


رویداد group box دوم :

// change Icon based on option chosen by sender
private void iconType_CheckedChanged( object sender, EventArgs e )
{
if ( sender == asteriskRadioButton ) // display asterisk Icon
iconType = MessageBoxIcon.Asterisk;

// display error Icon
else if ( sender == errorRadioButton )
iconType = MessageBoxIcon.Error;

// display exclamation point Icon
else if ( sender == exclamationRadioButton )
iconType = MessageBoxIcon.Exclamation;

// display hand Icon
else if ( sender == handRadioButton )
iconType = MessageBoxIcon.Hand;

// display information Icon
else if ( sender == informationRadioButton )
iconType = MessageBoxIcon.Information;

// display question mark Icon
else if ( sender == questionRadioButton )
iconType = MessageBoxIcon.Question;

// display stop Icon
else if ( sender == stopRadioButton )
iconType = MessageBoxIcon.Stop;

// only one option left--display warning Icon
else
iconType = MessageBoxIcon.Warning;
} // end method iconType_CheckChanged

// display MessageBox and Button user pressed

ممنون میشم راهنماییم کنین :قلب::قلب::قلب:

با تشکر:قلب: