Adding Items To A ListviewBox

Adding Items To A ListviewBox

Page 1 of 1

4 Replies - 2734 Views - Last Post: 28 July 2010 - 12:55 AM Rate Topic: -----

#1 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Adding Items To A ListviewBox

Posted 25 July 2010 - 09:44 AM

Hi
I am making a question and answer program and I sorted 1 issue out with the help of a member and am back for some more advice this time how to add items to a listview box so i will begin

Attached Image

so as you can see I have the design ready and all running great I can select a number and go to that question no problems at all

what I am now trying to do is when I click a button on another form in the collem where it states flag have a X put in the box but also be able to remove it as well.

So say I click the button on question 1 I what it to show an X in the flagged collem of question 1

so it would look like this

Question Flagged Answerd
1 X

and when i click on the button again it would look like this

Question Flagged Answerd
1

is this possible to do with a listview1 any help would be much appricated and I am very greatful for any advice given

if you don't know the answer and do know where I could find the answer Please leave a link so I can find the answer somewhere else

code I have so far

PictureBox1.Visible = True And PictureBox1.Visible = False
If PictureBox1.Visible = True Then
Form3.ListView1.Items(0) = ("1 X")
ElseIf PictureBox1.Visible = False Then
Form3.ListView1.Items(0) = ("1")
End If

this code worked for listbox1 but am getting errors in listview1

they are as follows

Error 1 Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem'
Error 2 Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem'

perhaps I have the code wrong for what I am trying to achive not sure but works perfectly with listbox1

Many Thanks For Any Help You Can Offer

Kind Regards

BJseal91

Is This A Good Question/Topic? 0
  • +

Replies To: Adding Items To A ListviewBox

#2 camckee316  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 277
  • Joined: 29-August 08

Re: Adding Items To A ListviewBox

Posted 25 July 2010 - 12:10 PM

have you tried
Form3.ListView1.Add.Items(0)=("1   X")
or
Form3.ListView.Add.Items = ("1   X")

Was This Post Helpful? 0
  • +
  • -

#3 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Re: Adding Items To A ListviewBox

Posted 25 July 2010 - 12:23 PM

good try but unfortuntly no sucsess it just gave the same error good try though
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Adding Items To A ListviewBox

Posted 25 July 2010 - 01:44 PM

Look at the error message it clearly tell you what you are doing wrong.

Quote

Value of type 'String' cannot be converted to System.Windows.Forms.ListViewItem'
'


You're passing a string where it expects a ListViewItem.
So either pass it an ListViewItem or use the properties on the existing one.

With Form3.ListView1.Add.Items(0)
 .Text="1" 'The first colum
 .SubItems(0).Text="X" ' The 2nd column
 .sunItems(1).Text="?" ' The 3rd column
end With

Was This Post Helpful? 0
  • +
  • -

#5 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Re: Adding Items To A ListviewBox

Posted 28 July 2010 - 12:55 AM

View PostBJseal91, on 25 July 2010 - 11:23 AM, said:

good try but unfortuntly no sucsess it just gave the same error good try though


Many Thanks for all the replies I have completed the project and now it is all working
thanks again

BJseal91
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1