Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 609

Display empty text when there are no items in ListView Windows forms

$
0
0

I'm trying to display an empty text message inside a listview when I have no items inside it (that's when the form is initialized).

I've tried searching different method out of which one is using the `OnPaint() event , but that didn't work out well...

Can someone help me out ?` Edit: this is one of the methods I've tried:

  protected override void WndProc(ref Message m)        {            base.WndProc(ref m);            if (m.Msg == 20)            {                if (this.Items.Count == 0)                {                    _b = true;                    Graphics g = this.CreateGraphics();                    int w = (this.Width - g.MeasureString(_msg,                      this.Font).ToSize().Width) / 2;                    g.DrawString(_msg, this.Font,                      SystemBrushes.ControlText, w, 30);                }                else                {                    if (_b)                    {                        this.Invalidate();                        _b = false;                    }                }            }            if (m.Msg == 4127) this.Invalidate();        }

Viewing all articles
Browse latest Browse all 609

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>