Note that there are some explanatory texts on larger screens.

plurals
  1. POListview background drawing problem C# Winform
    text
    copied!<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>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload