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. C# Multiple forms...

C# Multiple forms...

Scheduled Pinned Locked Moved C#
helpcsharpquestion
7 Posts 4 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.
  • A Offline
    A Offline
    afrodriguez
    wrote on last edited by
    #1

    Hi, I had to create my own form to get files from my directory because i had to add allot of functionality not available on the system dialog boxes (done with that) now my problem is i need to pass on the selected files from my directory form to my main form...i can't get this to happen...can anyone help??...this is how i'm calling my second form: private void mnu_Open_Click(object sender, System.EventArgs e) { Form2 myMenu = new Form2(); Menu.Show(); }

    D 1 Reply Last reply
    0
    • A afrodriguez

      Hi, I had to create my own form to get files from my directory because i had to add allot of functionality not available on the system dialog boxes (done with that) now my problem is i need to pass on the selected files from my directory form to my main form...i can't get this to happen...can anyone help??...this is how i'm calling my second form: private void mnu_Open_Click(object sender, System.EventArgs e) { Form2 myMenu = new Form2(); Menu.Show(); }

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      If I understand you correctly, you can have property ( or internal field) with data you want to pass... It can look like : // your dialog class Form2:.... { ... public string[] Files { get { // m_files are return m_files; } } } // somewhere in main program private void mnu_Open_Click(object sender, System.EventArgs e) { Form2 myMenu = new Form2(); myMenu.Show(); DoSomethingWith(myMenu.Files); } Does it help? bets regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

      M A 2 Replies Last reply
      0
      • D DavidNohejl

        If I understand you correctly, you can have property ( or internal field) with data you want to pass... It can look like : // your dialog class Form2:.... { ... public string[] Files { get { // m_files are return m_files; } } } // somewhere in main program private void mnu_Open_Click(object sender, System.EventArgs e) { Form2 myMenu = new Form2(); myMenu.Show(); DoSomethingWith(myMenu.Files); } Does it help? bets regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

        M Offline
        M Offline
        Matt Gerrans
        wrote on last edited by
        #3

        And out of mercy to those who might have to read your code, you might want to use a more meaningful name than "Form2" for the thing. As well, myMenu = new Form(); is a bit confusing -- is it a form or a menu? Additionally, you might want to use ShowDialog() and also set the dialog result values appropriately, so you can use your dialog as you would an OpenFileDialog, for example:

        if( openFileDialog.ShowDialog(this) == DialogResult.OK )
        {
        //... use openFileDialog.FileName and whatnot ...
        }

        Matt Gerrans

        A 1 Reply Last reply
        0
        • D DavidNohejl

          If I understand you correctly, you can have property ( or internal field) with data you want to pass... It can look like : // your dialog class Form2:.... { ... public string[] Files { get { // m_files are return m_files; } } } // somewhere in main program private void mnu_Open_Click(object sender, System.EventArgs e) { Form2 myMenu = new Form2(); myMenu.Show(); DoSomethingWith(myMenu.Files); } Does it help? bets regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

          A Offline
          A Offline
          afrodriguez
          wrote on last edited by
          #4

          Thanks that solved my problem.

          1 Reply Last reply
          0
          • M Matt Gerrans

            And out of mercy to those who might have to read your code, you might want to use a more meaningful name than "Form2" for the thing. As well, myMenu = new Form(); is a bit confusing -- is it a form or a menu? Additionally, you might want to use ShowDialog() and also set the dialog result values appropriately, so you can use your dialog as you would an OpenFileDialog, for example:

            if( openFileDialog.ShowDialog(this) == DialogResult.OK )
            {
            //... use openFileDialog.FileName and whatnot ...
            }

            Matt Gerrans

            A Offline
            A Offline
            afrodriguez
            wrote on last edited by
            #5

            Matt, I didn't ask you for your judgment i asked for some help. You unlike the other guy were of no assistance. Oh btw...I simplified the code down to a textbook manner so that i can get my point across without copying my entire file into the thread...next time give your opinion when asked for it.

            M 1 Reply Last reply
            0
            • A afrodriguez

              Matt, I didn't ask you for your judgment i asked for some help. You unlike the other guy were of no assistance. Oh btw...I simplified the code down to a textbook manner so that i can get my point across without copying my entire file into the thread...next time give your opinion when asked for it.

              M Offline
              M Offline
              Matt Gerrans
              wrote on last edited by
              #6

              Okay, sorry about adding the editorial. ;P I removed that part, but I hope at least the part about the ShowDialog() and the DialogResults was helpful. :) Matt Gerrans

              H 1 Reply Last reply
              0
              • M Matt Gerrans

                Okay, sorry about adding the editorial. ;P I removed that part, but I hope at least the part about the ShowDialog() and the DialogResults was helpful. :) Matt Gerrans

                H Offline
                H Offline
                Heath Stewart
                wrote on last edited by
                #7

                You don't need to apoligize for correcting bad examples. Many times in this forum some people post bad examples that foster bad coding in other developers. Nothing leads to poor quality software than code written half-assed.

                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