Listview help help

help with listview

Page 1 of 1

2 Replies - 1149 Views - Last Post: 19 January 2009 - 12:09 PM Rate Topic: -----

#1 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Listview help help

Posted 19 January 2009 - 07:56 AM

Hey it's me again...Basically, for my program I am doing I want the user to open images in to a listview box and when it's opened the current image shows in the listview box! Fine and dandy, I open another image and it shows however when I click on the other added image it stays on the current picture opened....I want it to be that when I click on the the other images they show in the picturebox. I can do this with a listbox and I can can also get this with the AXwindowsmediaplayer but not with a picturebox and listview. Any Ideas? code I am trying below! I am also trying to get it so that on opening a file a thumbnail image of the image file is shown in the listview...I am having issues with that, I had to remove the code as it caused serious crashes in my program.

   Private Sub btnOpener_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpener.Click

		OpenFileDialog1.Filter = "Bitmap Image(*.BMP)|*.BMP|Jpeg Image(*.JPG)|*.JPG|GIF Image(*.GIF)|*.GIF|TIFF Image(*.TIFF)|*.TIFF|Portable Network Graphic(*.PNG)|*.PNG|Icon Image(*.ICO)|*.ICO|All Files(*.*)|*.*"
		OpenFileDialog1.Title = "Open an Image file"
		OpenFileDialog1.FileName = ""
		OpenFileDialog1.InitialDirectory = ""
		OpenFileDialog1.FilterIndex = 2
		OpenFileDialog1.Multiselect = True
	   

		If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
			PictureBoxViewer.Image = Image.FromFile(OpenFileDialog1.FileName)

		End If



		For Each Me.strFilename In OpenFileDialog1.FileNames

			Dim ListItem As ListViewItem = New ListViewItem(Path.GetFileName(strFilename))
			ListItem.SubItems.Add(strFilename)
			ListView1.Items.Add(ListItem)
 Next
	End Sub



 Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
		Dim ListItem2 As ListViewItem = As new ListViewItem(strFilename)
		If ListItem2.Selected = True Then
			PictureBox1.Image = Image.FromFile(ListItem2.Index)
		End If
	
	End Sub 


Is This A Good Question/Topic? 0
  • +

Replies To: Listview help help

#2 kasbaba  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 133
  • Joined: 03-November 08

Re: Listview help help

Posted 19 January 2009 - 10:30 AM

Hi,

I presume you have two objects.
A picturebox and an object named PictureBoxViewer

Is PictureBoxViewer some kind of a container containing Picturebox1 ?

If it is a container then I think, you should re-write the following code:

Quote

If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBoxViewer.Image = Image.FromFile(OpenFileDialog1.FileName)
PictureBox1.Image = Image.FromFile (OpenFileDialog1.FileName)

End If


Hope this helps..

kasbaba

This post has been edited by kasbaba: 19 January 2009 - 10:31 AM

Was This Post Helpful? 0
  • +
  • -

#3 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Re: Listview help help

Posted 19 January 2009 - 12:09 PM

pictureboxviewer is the picturebox, i should have clarified that, my bad
the open file dialog stuff is all ok... it's the second part with the list view that i need help on...just need to get the image to change to the clicked image e.g

i have a picbox..I click the open button and choose an image "monkey" the image shows and the file name shows in the listview (fine). I now open another image "donkey" the image shows also and the file name is in the listview (fine). I want to be able to click on monkey and have that image show in the picturebox and vice versa...so when i add a variety of Images I an click on any one and it will be displayed in the picbox....
(not sure if that helps explain my predicament)

This post has been edited by developerman: 19 January 2009 - 12:15 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1