Hi,
in VWG ListView has event ListViewItemBindingEventArgs, so we can add (remove) controls ( combobox, textbox …) to SubItems. Is it possible to do something like this in Wisej?
Thank you for your help,
Page
When you type in the text boxes in the image attached you are causing the binding property to change, causing the data source to change causing the listview to reload the list because List<> is not BindingList<> and doesn’t keep the record index. Change it to BindingList<> and only the modified record will be updated. But:
Use a DataGridView or a DataRepeater instead.
You can’t add items to a data bound listview, the same way you cannot add rows to a data bound datagridview. Data bound controls have a data source and data should be added to the data source. You don’t get an exception using AddRange() because there is a missing check in Wisej which we’ll fix in the next build. If VWG allowed adding rows or items to a data bound control it was simply wrong.
In alternative use listView.Fill(data) to create the items (or rows) from a data source and don’t keep the data binding.
Hi,
I attached the sample, there are the problems I’m facing now
1) Adding controls to SubItems
//OK
e.ListViewItem.SubItems[0].Control = tbName;
e.ListViewItem.SubItems[1].Control = tbDesc;
//EXCEPTION
e.ListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem { Control = tbName });
e.ListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem { Control = tbDesc });
//OK
e.ListViewItem.SubItems.AddRange(new ListViewItem.ListViewSubItem[] { new ListViewItem.ListViewSubItem { Control = tbName }, new ListViewItem.ListViewSubItem { Control = tbDesc } });
2) When I change value in a textbox and move to other textbox, ListView refreshes all items. I think it should not.
Thanks for your help,
Page
Tried this:
this.listView1.DataSource = data; this.listView1.Items[0].SubItems[1].Control = new Button() { Text = "Test", Dock = DockStyle.Fill };
Works without issues.
You can add subitems directly when the listview is data bound. The exception is correct. Add items to the data source.
if you attach a small runnable test case we may be able to help you further.
Hi,
I followed the implementation of VWG and tried to add control to SubItems in ListViewItem, but it throws exception in Wisej. There is something wrong when Add ListViewSubItem to SubItems, please check the Wisej source.
Thanks for your help,
Page
Hi
You can use the listView1.Controls property to manage that
Using for example
listView1.Controls.Add(new button()) // specific control
listView1.Controls.AddRange(Control[] controls) // array of controls
Regards
Please login first to submit.