logo
VitNX3 Documentation

# VitNX_SectionPanel.OnPaint Method

Namespace: VitNX.UI.ControlsV1.Controls
Assembly: VitNX3 (in VitNX3.dll)
Raises the Paint event.
VB
C#
F#
C++
JScript
Copy

    protected override void OnPaint(
       PaintEventArgs e
    )

    This language is not supported or no code example is available.

#### Parameters

e
  PaintEventArgs

A PaintEventArgs that contains the event data.

Source code
VB
C#
F#
C++
JScript
Copy

    protected override void OnPaint(PaintEventArgs e)
     {
         var g = e.Graphics;
         var rect = ClientRectangle;

         // Fill body
         using (var b = new SolidBrush(Colors.GreyBackground))
         {
             g.FillRectangle(b, rect);
         }

         // Draw header
         var bgColor = ContainsFocus ? Colors.BlueBackground : Colors.HeaderBackground;
         var VitNXColor = ContainsFocus ? Colors.VitNXBlueBorder : Colors.VitNXBorder;
         var lightColor = ContainsFocus ? Colors.LightBlueBorder : Colors.LightBorder;

         using (var b = new SolidBrush(bgColor))
         {
             var bgRect = new Rectangle(0, 0, rect.Width, 25);
             g.FillRectangle(b, bgRect);
         }

         using (var p = new Pen(VitNXColor))
         {
             g.DrawLine(p, rect.Left, 0, rect.Right, 0);
             g.DrawLine(p, rect.Left, 25 - 1, rect.Right, 25 - 1);
         }

         using (var p = new Pen(lightColor))
         {
             g.DrawLine(p, rect.Left, 1, rect.Right, 1);
         }

         var xOffset = 3;

         using (var b = new SolidBrush(Colors.LightText))
         {
             var textRect = new Rectangle(xOffset, 0, rect.Width - 4 - xOffset, 25);

             var format = new StringFormat
             {
                 Alignment = StringAlignment.Near,
                 LineAlignment = StringAlignment.Center,
                 FormatFlags = StringFormatFlags.NoWrap,
                 Trimming = StringTrimming.EllipsisCharacter
             };

             g.DrawString(SectionHeader, Font, b, textRect, format);
         }

         // Draw border
         using (var p = new Pen(Colors.VitNXBorder, 1))
         {
             var modRect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);

             g.DrawRectangle(p, modRect);
         }
     }

    This language is not supported or no code example is available.

Applies to

#### .NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

#### .NET Core

Supported in: 5.0+, 6.0+
See Also
VitNX_SectionPanel Class
VitNX.UI.ControlsV1.Controls Namespace