Here is my code:
What I want to achieve is that when "PanelCode" field in my database had a value, I would not display it in the lvselected(listview), just the subitems.I had tried using this code:
but it was giving me an exception stating that "Item" is ReadOnly.How can I possibly do this thanks...
visual basic code:
Do While MyDataReader.Read Dim myItems = lvSelected.Items.Add(MyDataReader("PanelCode".ToString)) With myItems .SubItems.Add(MyDataReader("ExamName".ToString)) .subitems.add(MyDataReader("Price".ToString)) .subitems.add("1") End With Loop
What I want to achieve is that when "PanelCode" field in my database had a value, I would not display it in the lvselected(listview), just the subitems.I had tried using this code:
visual basic code:
If MyDataReader("PanelCode".ToString)<>"" then MyDataReader("PanelCode".ToString)="" End If
but it was giving me an exception stating that "Item" is ReadOnly.How can I possibly do this thanks...

How can I set the ListView Item no to show
chicagoclone
Dim myItems = lvSelected.Items.Add("")
Other than that, your use to ToString looks wrong. I assume you need MyDataReader("fieldname").ToString
lee anthony
It seems to me that, according to your code, you're setting MyDataReader, which could be readonly, to empty string. You could try to set your actual display (ListView) to empty string instead. Assuming ListView is not set to ReadOnly, you should be able to set ListView1.Items(i).Text = ""
Yun
st8floorsup
First problem is your use of ToString...It should be outide of the parameter...such as
Dim myItems = lvSelected.Items.Add(MyDataReader("PanelCode").ToString)
Then use String.IsNullOrEmpty for your comparison:
If
Not String.IsNullOrEmpty(MyDataReader("PanelCode").ToString) Then