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. STOP form_load

STOP form_load

Scheduled Pinned Locked Moved C#
questionhelp
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
    Cliffer
    wrote on last edited by
    #1

    hi, i have to stop the load of my form when i catch an error, i want to close the form. but if i write: try { ... } catch { Close(); } i get an error. because it's impossible to close form on load. someone has any ideas? how can i stop the load? thanks a lot. Cliffer

    R N 2 Replies Last reply
    0
    • C Cliffer

      hi, i have to stop the load of my form when i catch an error, i want to close the form. but if i write: try { ... } catch { Close(); } i get an error. because it's impossible to close form on load. someone has any ideas? how can i stop the load? thanks a lot. Cliffer

      R Offline
      R Offline
      Ricardo Casquete
      wrote on last edited by
      #2

      I don't know it if is what you really need... but try this. private void mdi_Load(object sender, System.EventArgs e) { try { throw new Exception ( "Error" ); } catch { this.Closing += new CancelEventHandler(mdi_Closing); OnClosing( new System.ComponentModel.CancelEventArgs ( false ) ); } } private void mdi_Closing(object sender, CancelEventArgs e) { System.Windows.Forms.Application.Exit (); } Hope It works Ricardo Casquete

      1 Reply Last reply
      0
      • C Cliffer

        hi, i have to stop the load of my form when i catch an error, i want to close the form. but if i write: try { ... } catch { Close(); } i get an error. because it's impossible to close form on load. someone has any ideas? how can i stop the load? thanks a lot. Cliffer

        N Offline
        N Offline
        Nicholas Butler
        wrote on last edited by
        #3

        Hi You don't say how you are showing the form. If you are showing it using ShowDialog, you can just set the DialogResult property:

        private void Form2_Load(object sender, System.EventArgs e)
        {
        try
        {
        ...
        }
        catch
        {
        DialogResult = DialogResult.Abort;
        }
        }

        ---------------------------- Be excellent to each other :) EasiReports[^] My free reporting component for WinForms.

        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