<p>I have a little problem with a Listview.</p>

<p>I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first column shows the error].  There is a a narrow strip that doesn't paint.  The width of that strip is approximately the same as a row header would be if I had a row header.  </p>

<p>If you have a thought on what can be done to make the background draw I'd love to hear it.  </p>

<p>Now just to try a new idea, I'm offering a ten vote bounty for the first solution that still has me using this awful construct of a mess of a pseudo grid view.  [I love legacy code.]</p>

<p><strong>Edit:</strong></p>

<p>Here is a sample that exhibits the problem.</p>

<pre><code>public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        ListView lv = new ListView();

        lv.Dock = System.Windows.Forms.DockStyle.Fill;
        lv.FullRowSelect = true;
        lv.GridLines = true;
        lv.HideSelection = false;
        lv.Location = new System.Drawing.Point(0, 0);
        lv.TabIndex = 0;
        lv.View = System.Windows.Forms.View.Details;
        lv.AllowColumnReorder = true;

        this.Controls.Add(lv);

        lv.MultiSelect = true;

        ColumnHeader ch = new ColumnHeader();
        ch.Name = "Foo";
        ch.Text = "Foo";
        ch.Width = 40;
        ch.TextAlign = HorizontalAlignment.Left;

        lv.Columns.Add(ch);

        ColumnHeader ch2 = new ColumnHeader();
        ch.Name = "Bar";
        ch.Text = "Bar";
        ch.Width = 40;
        ch.TextAlign = HorizontalAlignment.Left;

        lv.Columns.Add(ch2);

        lv.BeginUpdate();

        for (int i = 0; i &lt; 3; i++)
        {


            ListViewItem lvi = new ListViewItem("1", "2");

            lvi.BackColor = Color.Black;
            lvi.ForeColor = Color.White;

            lv.Items.Add(lvi);
        }
        lv.EndUpdate();
    }
}
</code></pre>

[{'answer_id': 60300, 'author': 'moobaa', 'author_id': 3569, 'author_profile': 'https://Stackoverflow.com/users/3569', 'pm_score': 1, 'selected': False, 'text': "<p>(Prior to the Edit...)</p>\n\n<p>I've just tried setting the BackColor on a System.Windows.Forms.ListView, and the color is applied across the control just fine (with and without images).</p>\n\n<p>Are you doing any Custom Painting at all?</p>\n"}, {'answer_id': 60339, 'author': 'moobaa', 'author_id': 3569, 'author_profile': 'https://Stackoverflow.com/users/3569', 'pm_score': 4, 'selected': True, 'text': '<p>Ah! I see now  :}</p>\n\n<p>You want hacky? I present unto you the following:</p>\n\n<pre><code>    ...\n    lv.OwnerDraw = true;\n    lv.DrawItem += new DrawListViewItemEventHandler( lv_DrawItem );\n    ...\n\nvoid lv_DrawItem( object sender, DrawListViewItemEventArgs e )\n{\n    Rectangle foo = e.Bounds;\n    foo.Offset( -10, 0 );\n    e.Graphics.FillRectangle( new SolidBrush( e.Item.BackColor ), foo );\n    e.DrawDefault = true;\n}\n</code></pre>\n\n<p>For a more inventive - and no less hacky - approach, you could try utilising the background image of the ListView  ;)</p>\n'}, {'answer_id': 80045, 'author': 'Dan Blair', 'author_id': 1327, 'author_profile': 'https://Stackoverflow.com/users/1327', 'pm_score': 0, 'selected': False, 'text': "<p>Ok I'm adding some additional solution notes. If you use the solution above you also need to insert a draw handler for the column headers, otherwise they won't paint.  The selected item rectangle also looks funny so you'll want to check for that in the lv_DrawItem function and implement a similar solution.  Remeber that highlighting is chosen at the system level and not in you application.  </p>\n"}, {'answer_id': 23231928, 'author': 'Libor', 'author_id': 148156, 'author_profile': 'https://Stackoverflow.com/users/148156', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://www.componentowl.com/better-listview" rel="nofollow noreferrer">Better ListView</a> (and free <a href="http://www.componentowl.com/better-listview-express" rel="nofollow noreferrer">Better ListView Express</a>) allows setting background image with various alignment settings (centered, tiled, stretched, fit, snap to border/corner). Alpha transparency is also supported:</p>\n\n<p><img src="https://i.stack.imgur.com/OZicy.png" alt="enter image description here"></p>\n'}]
['https://Stackoverflow.com/questions/60293', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1327/']