Because I would like to color every single element differently, I decided for the ListView
instead of the ListBox
, which can only colour all elements at once.
That means it should, so to speak, have only one column and insert the elements among each other, comparable to the command listBox.Items.Insert(0, "Item")
.
Which properties do I need to change in order to achieve that?
I already tried setting the View
Property to View.List
but as soon as there are too many elements in a row, it continues to insert the elements into a second row that I didn't even create and also can't find when I'm looking at Edit Columns
...
Click the various column headers in the ListView control. When you click the header, the contents of the ListView control are sorted in ascending order based on the column that you click. When you click the same column header again, that column is sorted in descending order.
List view (ListView) controls are used to display a collection of items, each having a text label and, optionally, an icon and a check box. List view can display items in several modes - with full-sized icons or small icons, with additional information displayed in columns on the right of the item, and so on.
A ListView control allows you to display a list of items with item text and, optionally, an icon to identify the type of item. For example, the Windows Explorer list of files is similar in appearance to a ListView control. It displays a list of the files and folders currently selected in the tree.
A list-view control is a window that displays a collection of items. List-view controls provide several ways to arrange and display items and are much more flexible than simple List Boxes. For example, additional information about each item can be displayed in columns to the right of the icon and label.
You can set the View
to Details
and set the HeaderStyle
to None
, and then by adding a column and setting its size to -1
force the column to use the same width as ListView
:
this.listView1.View = View.Details;
this.listView1.HeaderStyle = ColumnHeaderStyle.None;
this.listView1.FullRowSelect = true;
this.listView1.Columns.Add("", -2);
this.listView1.Items.Add("Something");
this.listView1.Items.Add("Something else").BackColor = Color.Red;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With