Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Draw a LINE on a TABCONTROL???

Reply
 
Old 03-10-2009   #1 (permalink)
Alan Mailer


 
 

Draw a LINE on a TABCONTROL???

Can someone spell out for me how in VB.NET I would draw a line across
a TablControl Page?

Thanks in advance.

My System SpecsSystem Spec
Old 03-12-2009   #2 (permalink)
Dawid Rutyna


 
 

Re: Draw a LINE on a TABCONTROL???

> Can someone spell out for me how in VB.NET I would draw a line across
Quote:

> a TablControl Page?
>
> Thanks in advance.
It was hard for me to draw this line, this is the solution:

(1) Mainly requires to draw the whole control

public partial class TabControlWithLine : TabControl
{
public TabControlWithLine()
{
InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw |
ControlStyles.UserPaint, true);
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics graphics = e.Graphics;
graphics.Clear(Color.White);
Pen pen = new Pen(Color.Black, 2);
graphics.DrawLine(pen, new Point(Width, 0), new Point(0, Height));
}
}

(2) Propably will be not enough for you

private void tabControl1_DrawItem(object sender,
System.Windows.Forms.DrawItemEventArgs e)
{
SolidBrush FillBrush = new SolidBrush(Color.Red);
Rectangle ItemRect = tabControl1.GetTabRect(e.Index);
Graphics graphics = e.Graphics;
graphics.FillRectangle(FillBrush, ItemRect);
Pen pen = new Pen(Color.Black, 2);
graphics.DrawLine(pen, new Point(ItemRect.Left, ItemRect.Bottom), new
Point(ItemRect.Right, ItemRect.Top));
}

As far as I know this control is painted by windows so there is not much we
can do about the painting.
Finally the website: http://dotnetrix.co.uk/tabcontrol.htm

Dawid Rutyna


My System SpecsSystem Spec
Old 03-12-2009   #3 (permalink)
Jeff Gaines


 
 

Re: Draw a LINE on a TABCONTROL???

On 12/03/2009 in message <gpbijo$es7$1@xxxxxx> Dawid Rutyna wrote:
Quote:

>It was hard for me to draw this line, this is the solution:
[snipped]

You can sometimes get away with putting a label on a control and reducing
its height to 1 or 2 pixels. Makes a reasonable low resource line.

--
Jeff Gaines
Damerham Hampshire UK
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Custom Control between tabcontrol and Outlook bar .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46