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. my function not functioning

my function not functioning

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

    i want to validate first if the form is already loaded or not. if it is already loaded the form will just prompt it again perform it windows state to normal and focus but does not duplicate the form.. private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (IsFormLoaded("form2")) { return; } Form1 frmshow = new Form1(); frmshow.MdiParent = this; frmshow.Show(); } private bool IsFormLoaded(string formName) { bool Load = false; for (int i = 0; i < (this.OwnedForms.Length) - 1; i++) { if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName") { this.OwnedForms[i].WindowState = FormWindowState.Normal; this.OwnedForms[i].Focus(); Load = true; } } return Load; }

    K P 2 Replies Last reply
    0
    • C crisjala

      i want to validate first if the form is already loaded or not. if it is already loaded the form will just prompt it again perform it windows state to normal and focus but does not duplicate the form.. private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (IsFormLoaded("form2")) { return; } Form1 frmshow = new Form1(); frmshow.MdiParent = this; frmshow.Show(); } private bool IsFormLoaded(string formName) { bool Load = false; for (int i = 0; i < (this.OwnedForms.Length) - 1; i++) { if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName") { this.OwnedForms[i].WindowState = FormWindowState.Normal; this.OwnedForms[i].Focus(); Load = true; } } return Load; }

      K Offline
      K Offline
      Khaniya
      wrote on last edited by
      #2

      why are you using hardcoded form name if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName") "formName" should be formName

      Life's Like a mirror. Smile at it & it smiles back at you.- P Pligrim So Smile Please

      1 Reply Last reply
      0
      • C crisjala

        i want to validate first if the form is already loaded or not. if it is already loaded the form will just prompt it again perform it windows state to normal and focus but does not duplicate the form.. private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (IsFormLoaded("form2")) { return; } Form1 frmshow = new Form1(); frmshow.MdiParent = this; frmshow.Show(); } private bool IsFormLoaded(string formName) { bool Load = false; for (int i = 0; i < (this.OwnedForms.Length) - 1; i++) { if (this.OwnedForms[i].Name.ToString().TrimStart() == "formName") { this.OwnedForms[i].WindowState = FormWindowState.Normal; this.OwnedForms[i].Focus(); Load = true; } } return Load; }

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Please, don't repost a question so quickly. Your original question is only a couple of questions down, so be patient and post any updates to your question on that one. Don't start a new thread as this is rude.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        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