I have an c# windowsform app with several forms and in one of the forms I have a 2 column listview. When I add the text to the items of the listview, nothing is shown. I know the items are getting added because the vertical scroll bar appears, and I checked that the items had the appropriate text in the debugger. Does anyone know why the text is not shown and how I can get them to appear? Apparently others have had this problem with listviews but I didn't see any solutions posted. The same thing happens in the listbox in another form - strings are getting added to the items of the listbox correctly but they are not shown. Thanks in advance.
Boy, do I feel stupid! I assumed the text color was defaulted to black but it was white, same as the backgound color. Thanks for your help!
Oops, maybe I was too hasty. That was the problem with the listbox but not the listview. The text color (fore color) for the listview was set to black and background color to white. Here is the code for the listview:
In load:
columnHeader2.Text = "col 1";
columnHeader1.TextAlign = HorizontalAlignment.Center;
columnHeader1.Width = this.Width / 2 - 6;
columnHeader2.Text = "col 2";
columnHeader2.TextAlign = HorizontalAlignment.Center;
columnHeader2.Width = this.Width / 2 - 6;
lvwCOMMIO.Columns.Add(columnHeader1);
lvwCOMMIO.Columns.Add(columnHeader2);
When I try to update the listview: (message1 and message2 are strings)
ListViewItem item1 = new ListViewItem(message1, 0);
item1.SubItems.Add(message2);
lvwCOMMIO.Items.Add(item1);
I was testing for InvokeRequired and using Invoke() with a delegate on the listview but it's false so I deleted that test.
Yes, I have the view type set to Details.