Does any one know how to wrap the text in a subitem? I have a list view with one subitem, which is a description of the item, sometimes it would be 3 to 4 lines. I would like all the text to show in the listview.
Hello!
I sort of found a easy solution.
Create a ListViewBox (i created with name lstScenarioDesc)and then copy this code and call it from page_load,
private void CreateMyListView()
{
// Set the view to show details.
lstScenarioDesc.View = View.Details;
// Allow the user to edit item text.
lstScenarioDesc.LabelEdit = true;
lstScenarioDesc.LabelWrap = true;
// Allow the user to rearrange columns.
lstScenarioDesc.AllowColumnReorder = true;
// Select the item and subitems when selection is made.
lstScenarioDesc.FullRowSelect = true;
// Display grid lines.
lstScenarioDesc.GridLines = true;
// Create columns for the items and subitems.
lstScenarioDesc.Columns.Add("Column 1", 100, HorizontalAlignment.Left);
lstScenarioDesc.Columns.Add("Column 2", 200, HorizontalAlignment.Left);
ListViewItem listItem1 = new ListViewItem("CPU");
ListViewItem listItem2 = new ListViewItem("");
ListViewItem listItem3 = new ListViewItem("");
listItem1.SubItems.Add(new ListViewItem.ListViewSubItem(
listItem1, "Something longer so it does not fit "));
listItem2.SubItems.Add(new ListViewItem.ListViewSubItem(
listItem2, "in one line.So I am trying."));
listItem3.SubItems.Add(new ListViewItem.ListViewSubItem(
listItem3, "And so multi line works sort off"));
lstScenarioDesc.Items.Add(listItem1);
lstScenarioDesc.Items.Add(listItem2);
lstScenarioDesc.Items.Add(listItem3);
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.