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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Close a form ?

Close a form ?

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studiohelpquestion
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.
  • A Offline
    A Offline
    Assaf82
    wrote on last edited by
    #1

    I develop an application constitute from many form. the first form (Connection) is to establish the database and after the first form in the application appear how i can close the connection form when the first form in the application appear. this is my code: private void btnCon_Click(object sender, EventArgs e) { try { dataConnection.Open(); MessageBox.Show(" Test Connection Succeded ", "Microsoft Visual Studio", MessageBoxButtons.OK, MessageBoxIcon.Information); strcon = dataConnection.ConnectionString; dataConnection.Close(); } catch (Exception ex) { MessageBox.Show(" Error - Connection " + ex.Message, "Microsoft Visual studio", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { CreditCard.ToBegin n = new CreditCard.ToBegin(); n.servcon = strcon; n.ShowDialog(); } } Assaf

    C E 2 Replies Last reply
    0
    • A Assaf82

      I develop an application constitute from many form. the first form (Connection) is to establish the database and after the first form in the application appear how i can close the connection form when the first form in the application appear. this is my code: private void btnCon_Click(object sender, EventArgs e) { try { dataConnection.Open(); MessageBox.Show(" Test Connection Succeded ", "Microsoft Visual Studio", MessageBoxButtons.OK, MessageBoxIcon.Information); strcon = dataConnection.ConnectionString; dataConnection.Close(); } catch (Exception ex) { MessageBox.Show(" Error - Connection " + ex.Message, "Microsoft Visual studio", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { CreditCard.ToBegin n = new CreditCard.ToBegin(); n.servcon = strcon; n.ShowDialog(); } } Assaf

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Change your static void main so it runs your connection form, then your main form. Or, just have your main form be the form that starts the app, and have it show the connection form on startup.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • A Assaf82

        I develop an application constitute from many form. the first form (Connection) is to establish the database and after the first form in the application appear how i can close the connection form when the first form in the application appear. this is my code: private void btnCon_Click(object sender, EventArgs e) { try { dataConnection.Open(); MessageBox.Show(" Test Connection Succeded ", "Microsoft Visual Studio", MessageBoxButtons.OK, MessageBoxIcon.Information); strcon = dataConnection.ConnectionString; dataConnection.Close(); } catch (Exception ex) { MessageBox.Show(" Error - Connection " + ex.Message, "Microsoft Visual studio", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { CreditCard.ToBegin n = new CreditCard.ToBegin(); n.servcon = strcon; n.ShowDialog(); } } Assaf

        E Offline
        E Offline
        e_zakhour
        wrote on last edited by
        #3

        form.Close(); Elie

        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