Display Image on 2nd form?
-
Hi, I have 2 forms, on one form i want to browse image and want to save them in array or arraylist and show on 2nd form that selected image. How would that be done? One more query is that if i want to show that image in 2nd form can i set the size of image to be shown in a proper place as thier will be some more images will be later on adding to that form as well. Please help. Thanks
-
Hi, I have 2 forms, on one form i want to browse image and want to save them in array or arraylist and show on 2nd form that selected image. How would that be done? One more query is that if i want to show that image in 2nd form can i set the size of image to be shown in a proper place as thier will be some more images will be later on adding to that form as well. Please help. Thanks
private void browseBtn_Click(object sender, EventArgs e) { openFile.InitialDirectory = @"C:\"; openFile.Filter = "JPEG files (*.jpg)|*.jpg|GIF files (*.gif)|*.gif | BMP files (*.bmp)|*.bmp"; openFile.FilterIndex = 2; openFile.RestoreDirectory = true; if (openFile.ShowDialog() != DialogResult.Cancel) { imgTextbox.Text = openFile.FileName; } else { imgTextbox.Text = ""; } private void LoadGameButton_Click(object sender, EventArgs e) { TicTacToe tic=new TicTacToe(usernametextBox.Text); tic.Show(); this.Hide(); }
To be more specific the browse action on first form now when i select image in the textbox and click on loadgamebutton that selected image should appear on next form. I added Picturebox tool on 2nd form as well but dont know know how to implement the above functionality. Thanks -
private void browseBtn_Click(object sender, EventArgs e) { openFile.InitialDirectory = @"C:\"; openFile.Filter = "JPEG files (*.jpg)|*.jpg|GIF files (*.gif)|*.gif | BMP files (*.bmp)|*.bmp"; openFile.FilterIndex = 2; openFile.RestoreDirectory = true; if (openFile.ShowDialog() != DialogResult.Cancel) { imgTextbox.Text = openFile.FileName; } else { imgTextbox.Text = ""; } private void LoadGameButton_Click(object sender, EventArgs e) { TicTacToe tic=new TicTacToe(usernametextBox.Text); tic.Show(); this.Hide(); }
To be more specific the browse action on first form now when i select image in the textbox and click on loadgamebutton that selected image should appear on next form. I added Picturebox tool on 2nd form as well but dont know know how to implement the above functionality. ThanksThanks it worked but one more thing is how to give size to that image as it has been passed as a parameter. I want to give specific size to image when its loaded? Here is my code
Login.cs private void LoadGameButton_Click(object sender, EventArgs e) { TicTacToe tic=new TicTacToe(usernametextBox.Text,imgTextbox.Text); tic.Show(); this.Hide(); }
TicTacToe.cs public TicTacToe(string strText,string img) { InitializeComponent(); if (strText.Equals("")) { label2.Text = "Guest"; } else { label2.Text = strText; pictureBox1.Load(img); } }
-
Thanks it worked but one more thing is how to give size to that image as it has been passed as a parameter. I want to give specific size to image when its loaded? Here is my code
Login.cs private void LoadGameButton_Click(object sender, EventArgs e) { TicTacToe tic=new TicTacToe(usernametextBox.Text,imgTextbox.Text); tic.Show(); this.Hide(); }
TicTacToe.cs public TicTacToe(string strText,string img) { InitializeComponent(); if (strText.Equals("")) { label2.Text = "Guest"; } else { label2.Text = strText; pictureBox1.Load(img); } }
It worked now the image is in proper shape in the picture box but now the next question is "how u will put them in some arraylist so i can show multiple images at one time in the picturebox on the form". Thanks
-
It worked now the image is in proper shape in the picture box but now the next question is "how u will put them in some arraylist so i can show multiple images at one time in the picturebox on the form". Thanks
Any help please.. :confused:
-
Any help please.. :confused:
PERFECT PERFECT IT WORKED THANKS A MILLION..THANKS THANKS