Edited: I actually fixed the problem I originally set out to have help with. Now I'm stuck understanding how I can implement a Click selection. Obviously for a PictureBox with a set name, all you do is make a click event for it then provide the selection code (which I already have) within that event. But what about for my current situation, whereby PictureBoxes are created during runtime/loading of the form, depending on a user's database? I don't know the name of these PictureBoxes so I have no idea how to create an event for them.
I also need an event handler for when a row is added, but after its first column is entered. I've tried RowsAdded, but it occurs before column 1 is added (which is film name and I need the film name to utilize a function); SelectionChanged is not an option since this only needs to occur when a row is added & after 1st column is entered as well. I've also tried making a double event handler sub (RowsAdded + CellLeave), but they do not share the same parameters so I think this is why they did not work.
To quickly understand what I'm doing, it might help for you to see image of my program (uploaded to imgur.com): Film Manager
' I utilize a datagridview for to view my database. The big left poster film image is the currently selected film/row. I use this same code to get the smaller image for all the movies in my database
' All the movies of the database are in a wide panel spanning from the big film poster all the way to the right, and the panel's set to Autoscrooll if the posters go off the screen. These poster images will stay there once the form is loaded, while only the big poster image changes depending on row selection (already working perfectly).
---------------------------------------
I'm on the very last feature of my program (a movie manager) thanks to the help that the people of these forums have so graciously offered. However, I'm stuck with a problem I describe below. It may look like a lot but once you understand what's going on, it seems like a pretty simple problem, but nevertheless still a problem I haven't been able to remedy yet.
I also need an event handler for when a row is added, but after its first column is entered. I've tried RowsAdded, but it occurs before column 1 is added (which is film name and I need the film name to utilize a function); SelectionChanged is not an option since this only needs to occur when a row is added & after 1st column is entered as well. I've also tried making a double event handler sub (RowsAdded + CellLeave), but they do not share the same parameters so I think this is why they did not work.
To quickly understand what I'm doing, it might help for you to see image of my program (uploaded to imgur.com): Film Manager
' I utilize a datagridview for to view my database. The big left poster film image is the currently selected film/row. I use this same code to get the smaller image for all the movies in my database
' All the movies of the database are in a wide panel spanning from the big film poster all the way to the right, and the panel's set to Autoscrooll if the posters go off the screen. These poster images will stay there once the form is loaded, while only the big poster image changes depending on row selection (already working perfectly).
---------------------------------------
I'm on the very last feature of my program (a movie manager) thanks to the help that the people of these forums have so graciously offered. However, I'm stuck with a problem I describe below. It may look like a lot but once you understand what's going on, it seems like a pretty simple problem, but nevertheless still a problem I haven't been able to remedy yet.
Code:
' The Mother Loop
For CurrentRowIndex As Integer = 0 To RowCount
'Dim currentrowindex As Integer = 1
Dim CurrentRow As DataGridViewRow = FilmsDataGridView.Rows(CurrentRowIndex)
FilmName = CurrentRow.Cells(0).Value.ToString
Dim URLText As String = RetrieveFilmInfo()
' Retrieves film poster image URL
Dim BeginString As String = URLText.IndexOf("http")
Dim EndString As String = URLText.IndexOf(""",""imdbRating""")
Dim PosterURL As String = URLText.Substring(BeginString, EndString - BeginString)
Dim Poster As PictureBox = New PictureBox()
' Retrieves film poster image
If LoadIntoMemoryToolStripMenuItem.Checked Then
Dim ImageInBytes() As Byte = MyWebClient.DownloadData(PosterURL)
Dim ImageStream As New IO.MemoryStream(ImageInBytes)
Poster.Image = New System.Drawing.Bitmap(ImageStream)
ElseIf SaveToHDToolStripMenuItem.Checked Then
Dim Destination As String = "C:\Users\Rmlee\Documents\Visual Studio 2010\Projects\FilmProj\Film Posters\" + FilmName + ".jpg"
If System.IO.File.Exists(Destination) Then
Poster.Image = Image.FromFile(Destination)
Else
MyWebClient.DownloadFile(PosterURL, Destination)
Poster.Image = Image.FromFile(Destination)
End If
End If
Panel1.Controls.Add(Poster)
Poster.Size = New Size(164, 224)
Poster.Image = ScaleImage(Poster.Image, 224)
Dim x = 2
If CurrentRowIndex = 0 Or CurrentRowIndex = 1 Then
x = 48 ' Beginning poster image column X coordinate
ElseIf CurrentRowIndex > 1 And CurrentRowIndex Mod 2 = 0 Then ' Changes X coordinate only if its on the next column of poster images
x += 188
End If
If CurrentRowIndex Mod 2 = 0 Then ' Even
Poster.Location = New Point(x, 26)
ElseIf CurrentRowIndex Mod 2 = 1 Then ' Odd
Poster.Location = New Point(x, 226)
End If
Next