Hi,
I have a problem with Repaint my control. At first my control Create correctly. But with every changes like move scroll or anythings else my contrlo will be repaint. How can I avoid repainting in c#
it's my Event ONPaint :
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
if (_BorderStyle == BorderStyle.Fixed3D)
{
e.Graphics.DrawRectangle(SystemPens.GradientActive Caption, ClientRectangle.Left,
ClientRectangle.Top, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
}
else if (_BorderStyle == BorderStyle.FixedSingle)
{
e.Graphics.DrawRectangle(SystemPens.WindowText, ClientRectangle.Left,
ClientRectangle.Top, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
}
if (Text != "None" && _bayStructure.Cells.Count > 0)
{
RestartLabels();
foreach (KeyValuePair<string, Rectangle> cell in _bayStructure.Cells)
{
DrawCell(e.Graphics, cell, Focused &&
cell.Key == SelectedItem.Key ? Status.Selected : Status.None);
DrawTier(e.Graphics, cell);
if (cell.Value.Top > _bayStructure.Floor)
{
DrawFooter(e.Graphics, format, cell);
}
else
{
DrawHeader(e.Graphics, format, cell);
}
}
if (_bayStructure.EnforceZero)
{
if (_bayStructure.DeckSize % 2 == 0)
{
DrawHeader(e.Graphics, format);
}
if (_bayStructure.HatchSize % 2 == 0)
{
DrawFooter(e.Graphics, format);
}
}
e.Graphics.DrawRectangle(SystemPens.WindowText, _bayStructure.CoverRectangle);
e.Graphics.DrawString(Text, Font, SystemBrushes.WindowText, ClientRectangle.Width / 2,
_bayStructure.PlanRectangle.Y + _bayStructure.PlanRectangle.Height +
(_PlanFooter && _foot_titles.Count > 0 ? 20 : 6), format);
}
else
{
e.Graphics.DrawString("NONE", Font, SystemBrushes.WindowText,
ClientRectangle.Width / 2, 20, format);
}
}
Please help me to resolve this Problem. Please MAil me if you have any reply