c# - Two side button display on a table -


i want automatically switch on / off electric appliances. want add 2 side button in tableview . how can this?enter image description here

you override how button drawn along boolean value hold on/off state of control. quick ugly attempt cleaned little work is:

class onoffbutton : button {      bool on = true;      protected override void onpaint(painteventargs pevent)     {         pevent.graphics.clear(this.backcolor);         pevent.graphics.drawrectangle(pens.blue, 0, 0, 85, 25);         if (on)         {             pevent.graphics.drawstring("on", new font("microsoft sans serif", 8, fontstyle.bold), brushes.black, 5, 5);             pevent.graphics.fillrectangle(brushes.gray, 50, 1, 35, 24);         }         else         {             pevent.graphics.drawstring("off", new font("microsoft sans serif", 8, fontstyle.bold), brushes.black, 50, 5);             pevent.graphics.fillrectangle(brushes.gray, 1, 1, 35, 24);         }     }      protected override void onclick(eventargs e)     {         on = !on;         invalidate();     }      public bool on { { return on; } } } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -