c# - How to draw only selected borders on a control -


i building custom control , need paint top border. how can done?

edit: using code:

protected override void onpaint(painteventargs e) {     if (!this.designmode)     {         rectangle bounds = this.clientrectangle;         graphicspath topedge = new graphicspath();         topedge.startfigure();         topedge.addline(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);         topedge.closefigure();         e.graphics.drawpath(new pen(systemcolors.activeborder, 1), topedge);     }     base.onpaint(e); } 

this works when there no nested controls inside custom control. once start add controls, seem over-draw border line.

use controlpaint.drawborder method. article draw border around c# winform control: following adds border around control:

protected override void onpaint(painteventargs e) {   base.onpaint(e);   controlpaint.drawborder(e.graphics, clientrectangle,                             color.black, border_size, buttonborderstyle.inset,                             color.black, border_size, buttonborderstyle.inset,                             color.black, border_size, buttonborderstyle.inset,                             color.black, border_size, buttonborderstyle.inset); }  

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -