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. Error loading Windows Form from console App

Error loading Windows Form from console App

Scheduled Pinned Locked Moved C#
help
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.
  • G Offline
    G Offline
    Gumnaam
    wrote on last edited by
    #1

    I am trying to load a window form from a console App. I inlcude System.Windows and System.Windows.Forms in my project but when I try to load the form by doing Form abc = new Form(params) abc.Show() it doesn't load i.e. it doesn't pop up. Interestingly if I add a MessageBox.Show statement the form loads. Would like to know what's going on here.

    N D 2 Replies Last reply
    0
    • G Gumnaam

      I am trying to load a window form from a console App. I inlcude System.Windows and System.Windows.Forms in my project but when I try to load the form by doing Form abc = new Form(params) abc.Show() it doesn't load i.e. it doesn't pop up. Interestingly if I add a MessageBox.Show statement the form loads. Would like to know what's going on here.

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Gumnaam wrote: Form abc = new Form(params) abc.Show() The following works for me:

      using System;
      using System.Windows.Forms;

      public class test
      {
      public test(){}

      public class nick : System.Windows.Forms.Form
      {
      	public nick(){}
      }
      
      public static void Main(string\[\] args)
      {
      	test t= new test();
      	nick n = new nick();
      	n.ShowDialog();
      }		
      

      }

      - Nick Parker
      My Blog | My Articles

      1 Reply Last reply
      0
      • G Gumnaam

        I am trying to load a window form from a console App. I inlcude System.Windows and System.Windows.Forms in my project but when I try to load the form by doing Form abc = new Form(params) abc.Show() it doesn't load i.e. it doesn't pop up. Interestingly if I add a MessageBox.Show statement the form loads. Would like to know what's going on here.

        D Offline
        D Offline
        Danny Rodriguez
        wrote on last edited by
        #3

        try something like this instead SomeForm form = new SomeForm(); form.ShowDialog(); the code above returns a DialogResult but you dont need to necessarily get that value unless you want something back from the user regardless of this - why would you be adding gui elements to a console application to begin with - you might want to create a Windows Forms Application instead.. Danny!

        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