1 Replies - 7254 Views - Last Post: 15 July 2010 - 10:05 AM Rate Topic: -----

#1 dchw  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 76
  • Joined: 07-February 09

Windows Form from a Console App

Posted 15 July 2010 - 09:16 AM

I am working on an application that needs to have both a command-line AND windows form interface. I have designed the form, and written a basic console app. The issue comes when I try to display the GUI, as the application is a Console project in VS2008. I do the following:

Dim Apply As Boolean = False
Dim Check As Boolean = False

' Snip.

If Not Apply And Not Check Then
    Dim GUI As New PackManGUI
    GUI.Visible = True
End If



And in the Form:

Private Sub PackManGUI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Populates a treeview
End Sub



And the GUI flashes for a second, but then goes away. How do I make the GUI stay up, and wait for input?

Edited to add more code, and clarity.

This post has been edited by dchw: 15 July 2010 - 09:19 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Windows Form from a Console App

#2 dchw  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 76
  • Joined: 07-February 09

Re: Windows Form from a Console App

Posted 15 July 2010 - 10:05 AM

Solved it! I needed to use System.Windows.Forms.Application.Run - the form was closing since the program terminates at the end of Sub Main. This method simply loops on the form, like a Windows Form Application would. Documentation here.

If Not Apply And Not Check Then
    Dim GUI As New PackManGUI
    System.Windows.Forms.Application.Run(GUI)
End If


This post has been edited by dchw: 15 July 2010 - 10:07 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1