Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when a button click occurs button backcolor changes
C#
protected void RadioButtonList2_SelectedIndexChanged(object sender, EventArgs e)
   {
       Button2.BackColor = System.Drawing.Color.YellowGreen;
   }


i Want to avoid the change of color of button if again it happens
plz provide the needfull
Posted
Comments
BillWoodruff 20-Feb-14 20:39pm    
What is the relationship of the RadioButtons to 'Button2 ? Is 'Button2 a RadioButton ?

You need to give more details.

 
Share this answer
 
This method will reset all the control's backcolor to its default one. So invoke this method wherever you want.
C#
// Reset all the controls to the user's default Control color.
private void ResetAllControlsBackColor(Control control)
{
   control.BackColor = SystemColors.Control;
   control.ForeColor = SystemColors.ControlText;
   if(control.HasChildren)
   {
      // Recursively call this method for each child control.
      foreach(Control childControl in control.Controls)
      {
         ResetAllControlsBackColor(childControl);
      }
   }
}

src : msdn[^]

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900