Draw persistent grid in TabPage (.Net, C#) -
i need display persistent grid in tabpage. problems instantly solved if draw entire non-visible portion of tabpage , prevent graphics being erased when scrolling.
the other solution can think of tracking scroll position in tab , basing grid drawn that.
to draw in first place, had create eventhandler tabpage.paint.
//code removed this method draws vertical , horizontal lines create grid within visible tab, continues draw whenever paint event occurs (i.e. scrolling), creates overlapping lines , aren't aligned size of current visible area of tab.
maybe work you:
public partial class form1 : form { public form1() { initializecomponent(); const int gridspacing = 20; const int linethickness = 1; bitmap bmp = new bitmap(gridspacing, gridspacing); using (system.drawing.pen pen = new system.drawing.pen(color.blue, linethickness)) { using (graphics g = graphics.fromimage(bmp)) { g.clear(this.backcolor); g.drawline(pen, 0, bmp.height - pen.width, bmp.width, bmp.height - pen.width); // horizontal g.drawline(pen, bmp.width - pen.width, 0, bmp.width - pen.width, bmp.height); // vertical } } foreach (tabpage tp in tabcontrol1.tabpages) { tp.backgroundimage = bmp; tp.backgroundimagelayout = imagelayout.tile; } } }
Comments
Post a Comment