logo
VitNX3 Documentation

# VitNX_ListView.PaintContent Method

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

    protected override void PaintContent(
       Graphics g
    )

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

#### Parameters

g
  Graphics

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

    protected override void PaintContent(Graphics g)
     {
         var range = ItemIndexesInView().ToList();

         if (range.Count == 0)
             return;

         var top = range.Min();
         var bottom = range.Max();

         for (var i = top; i <= bottom; i++)
         {
             var width = Math.Max(ContentSize.Width, Viewport.Width);
             var rect = new Rectangle(0, i * ItemHeight, width, ItemHeight);

             // Background
             var odd = i % 2 != 0;
             var bgColor = !odd ? Colors.HeaderBackground : Colors.GreyBackground;

             if (SelectedIndices.Count > 0 && SelectedIndices.Contains(i))
                 bgColor = Focused ? Colors.BlueSelection : Colors.GreySelection;

             using (var b = new SolidBrush(bgColor))
             {
                 g.FillRectangle(b, rect);
             }

             // DEBUG: Border
             /*using (var p = new Pen(Colors.VitNXBorder))
             {
                 g.DrawLine(p, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
             }*/

             // Icon
             if (ShowIcons && Items[i].Icon != null)
             {
                 g.DrawImageUnscaled(Items[i].Icon, new Point(rect.Left + 5, rect.Top + (rect.Height / 2) - (_iconSize / 2)));
             }

             // Text
             using (var b = new SolidBrush(Items[i].TextColor))
             {
                 var stringFormat = new StringFormat
                 {
                     Alignment = StringAlignment.Near,
                     LineAlignment = StringAlignment.Center
                 };

                 var modFont = new Font(Font, Items[i].FontStyle);

                 var modRect = new Rectangle(rect.Left + 2, rect.Top, rect.Width, rect.Height);

                 if (ShowIcons)
                     modRect.X += _iconSize + 8;

                 g.DrawString(Items[i].Text, modFont, b, modRect, stringFormat);
             }
         }
     }

    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_ListView Class
VitNX.UI.ControlsV1.Controls Namespace