Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Display Image on 2nd form?

Display Image on 2nd form?

Scheduled Pinned Locked Moved C#
databasedata-structureshelpquestion
6 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haroon1980
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • H haroon1980

      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

      H Offline
      H Offline
      haroon1980
      wrote on last edited by
      #2

      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

      H 1 Reply Last reply
      0
      • H haroon1980

        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

        H Offline
        H Offline
        haroon1980
        wrote on last edited by
        #3

        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); } }

        H 1 Reply Last reply
        0
        • H haroon1980

          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); } }

          H Offline
          H Offline
          haroon1980
          wrote on last edited by
          #4

          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

          H 1 Reply Last reply
          0
          • H haroon1980

            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

            H Offline
            H Offline
            haroon1980
            wrote on last edited by
            #5

            Any help please.. :confused:

            H 1 Reply Last reply
            0
            • H haroon1980

              Any help please.. :confused:

              H Offline
              H Offline
              haroon1980
              wrote on last edited by
              #6

              PERFECT PERFECT IT WORKED THANKS A MILLION..THANKS THANKS

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups