B
Burak
Hello,
I have two quick questions about adding a
ListViewItem to windows forms combobox and listbox.
1) When I try to add a listview item to a combobox
using the following code
lstFrgnTables.DataSource = ds.Tables(0)
lstFrgnTables.DisplayMember = "TABLE_NAME"
lstFrgnTables.ValueMember = "TABLE_NAME"
Dim item = New System.Windows.Forms.ListViewItem("--
select table -- ", 0)
lstFrgnTables.Items.Add(item).ToString()
I get the following error
"Cannot modify the items collection when the datasource
property is set."
If i add this item before the data source is set, it
just gets overwritten after the data source is set.
How can I fix this?
2) When I add a list view item to a listbox using the
following code
Dim strSelect As String
strSelect = lstFrgnKeys.SelectedValue
Dim item = New
System.Windows.Forms.ListViewItem(strSelect)
lstForeignKeys.Items.Add(item)
the item gets added but it appears as
ListViewItem: {<value>}
How can I just have the <value> appear?
Thank you,
Burak
I have two quick questions about adding a
ListViewItem to windows forms combobox and listbox.
1) When I try to add a listview item to a combobox
using the following code
lstFrgnTables.DataSource = ds.Tables(0)
lstFrgnTables.DisplayMember = "TABLE_NAME"
lstFrgnTables.ValueMember = "TABLE_NAME"
Dim item = New System.Windows.Forms.ListViewItem("--
select table -- ", 0)
lstFrgnTables.Items.Add(item).ToString()
I get the following error
"Cannot modify the items collection when the datasource
property is set."
If i add this item before the data source is set, it
just gets overwritten after the data source is set.
How can I fix this?
2) When I add a list view item to a listbox using the
following code
Dim strSelect As String
strSelect = lstFrgnKeys.SelectedValue
Dim item = New
System.Windows.Forms.ListViewItem(strSelect)
lstForeignKeys.Items.Add(item)
the item gets added but it appears as
ListViewItem: {<value>}
How can I just have the <value> appear?
Thank you,
Burak