private void PictureBox_Click(object sender, EventArgs e) { PictureBox pic = sender as PictureBox; MovieTitle title = titles.First(x => x.Image == pic); chosenMovie = title.Name; HomeScreen = true; new MovieDescription().Show(); HomeScreen = false; }
private void PictureBox_MouseEnter(object sender, EventArgs e) { // Get the MovieTitle object that contains this picture box MovieTitle title = titles.First(x => x.Image == sender); Label label = title.Label; // Measure the height of the wrapped text in the label var textSize = TextRenderer.MeasureText(label.Text, label.Font, new Size(label.Size.Width, int.MaxValue), // The bounding box stretches downwards so that the resulting text size is not limited TextFormatFlags.WordBreak // Specify that the lines should break when they extend past the label width ); // Set the label size to the newly measured text size label.Size = new Size(label.Size.Width, Math.Max(label.Size.Height, textSize.Height + 2)); }
private void PictureBox_MouseLeave(object sender, EventArgs e) { MovieTitle title = titles.First(x => x.Image == sender); title.Label.Size = new Size(title.Label.Width, 20); }