I’m migrating a VWGui project and I’m trying to find a way in which I can add a control (such as a button) to a ListViewItem. Before, I did it this way:
item.SubItems[i] = new ListViewItem.ListViewSubControlItem(item, control); (error: cannot convert Wisej.Web.Control to string)
And I assigned the property to the column like this:
listView.Columns[i].Type = ListViewColumnType.Control; (error: ListView does not contain a definition for “Type”)
And I also had a function that responded to the event “ListViewItemFormattingEventArgs” (error: ListViewItemFormattingEventArgs can’t be found):
private void listView_ItemFormatting(object sender, ListViewItemFormattingEventArgs e)
{
}
Are there any ways in which I can do these things with Wisej?
Instead of item.SubItems[i] = new ListViewItem.ListViewSubControlItem(item, control);
you need to do this: item1.SubItems[i].Control = new Button();
Code sample:
// Add Items to the ListView
ListViewItem item1 = new ListViewItem("Item 1");
item1.SubItems.Add("Subitem 1");
ListViewItem item2 = new ListViewItem("Item 2");
item2.SubItems.Add("Subitem 2");
listView1.Items.Add(item1);
listView1.Items.Add(item2);
//Set the Control of the first subitem of item1 to be a button with the text "button text"
item1.SubItems[0].Control = new Button("button text");
I’ve also attached a simple project showing a button in a ListView as the Control of a SubItem.
Relevant documentation:
ListView
ListViewItem
ListViewSubItem
-Julie
Please login first to submit.