Results 1 to 3 of 3

Thread: How to load corrosponding picture into picturebox??

  1. #1

    Thread Starter
    Member Warad's Avatar
    Join Date
    Feb 2008
    Location
    Netherlands
    Posts
    63

    How to load corrosponding picture into picturebox??

    Hi,

    I have a datagridview filled with movie titles.
    Below the datagridview i have a picturebox.
    I have a folder filled with cover images in c:\covers

    What i try to do is this:
    When i click a name in the datagridview the corrosponding picture is automaticaly loaded in the picturebox.

    does anybody know how that works?

    Warad

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: How to load corrosponding picture into picturebox??

    do you have the filename displayed in your datagridview?

    you could use an 2d array to associate a friendly name (as displayed in your datagridview) with the filename

  3. #3
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: How to load corrosponding picture into picturebox??

    Well, I am not familiar with a datagrid view,

    But all you do is do this:

    Dim sMovieTitles() As String = {"Spider Man 3", "Fantastic Four"}
    Dim sMoviePaths() As String = {"C:\Covers\Spiderman3.jpg", "C:\Covers\FantasticFour.jpg"}

    Then you fill the datagrid with sMovieTitles, so that when you click an item
    you will be able to retrieve the clicked item's image by Image.FromFile(sMoviePaths(IndexOfSelectedItem))

    That's how I would do it in a combo box, IndexOfSelectedItem would be a variable you would set to the index of the current item selected in the data grid..

    I am not familiar with them so I can not be more accurate, but that might help somewhat.

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width