Hello ppl!

I am manually drawing tab items in a TabControl by using a handler attached
to the DrawItem event on such control. I am using rectangles inside the
Item's region
for the background and drawing strings for text using the graphics object
provided in the DrawItemEventArgs. I al also painting the aread just to the
right of the last tab with another rectangle in the same DrawItem event.
The form runs just fine and I can see the tabs asd intended on the initial
load. However, as I move the form to either the left or right just beyond
the screen, my painted rectangle simply dissapears or gets smeared. If the
form is moved beyog the screen's upper or lower boundaries the rectangle gets
painted again. This also happens if another window is on top of the
tabcontrol. I tried timers for refreshing the control and the form. Tried
also a refresh on the form on a Move event and managed to eliminate the
problem is the form moves beyond the right screen boundary but still the
same problem on the left boundary. Anyway I can work around this?
Thanks in advance

sampe code of the event handler:
private void tabControl1_DrawItem(object sender,
System.Windows.Forms.DrawItemEventArgs e)
{
Graphics g = e.Graphics;
int lastTabIndex = this.tabControl1.TabPages.Count-1;

System.Drawing.StringFormat textFormat = new StringFormat();
textFormat.Alignment = StringAlignment.Center;
textFormat.LineAlignment = StringAlignment.Center;
textFormat.Trimming = StringTrimming.None;
textFormat.FormatFlags = StringFormatFlags.NoWrap;

Rectangle tabRect = this.tabControl1.GetTabRect(e.Index);
Rectangle lastTabRect = this.tabControl1.GetTabRect(lastTabIndex);

//filler rectangle beyond last tab
g.FillRectangle(new SolidBrush(Color.Blue), lastTabRect.Right,
lastTabRect.Top, this.tabControl1.DisplayRectangle.Width,
lastTabRect.Height);
//tab Item background
g.FillRectangle(new SolidBrush(Color.Red), tabRect);
//Item text
g.DrawString(this.tabControl1.TabPages[e.Index].Text,
e.Font,
new SolidBrush(Color.White),
tabRect,
textFormat);
}