c# - Simple ON/OFF toggle button with image -


i'm working on winforms project i'm trying create on/off toggle button uses 2 separate images (both located in project resources) both "on" setting, , "off" setting.

based on i've found online, i've used checkbox appearance set "button".

here code i've got far button:

    private void togglebutton_checkedchanged(object sender, eventargs e)     {         if (togglebutton.checked)         {             togglebutton.backgroundimage.equals(properties.resources.togglebutton_on);         }         else         {             togglebutton.backgroundimage.equals(properties.resources.togglebutton_off);         }     } 

for reason nothing happens when click on button, , i'm not sure i've done wrong here.

basically, i'd background image cycle , fourth between togglebutton_on , togglebutton_off when user clicks on button.

change code to:

   private void togglebutton_checkedchanged(object sender, eventargs e)     {         if (togglebutton.checked)             togglebutton.backgroundimage = properties.resources.togglebutton_on;         else             togglebutton.backgroundimage = properties.resources.togglebutton_off;     } 

the .equals checking equality can override in own classes.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -