How can we navigate fron one form to other form...

Can you explain this

Re: Windows Forms General How can we navigate fron one form to other form...


You're going to have to be more precise in what you want to do.

Do you need help loading one form from another Do you need help having an event on one form cause an action in another form Are you having problems with leaving two forms active What exactually is it that you need help with

Re: Windows Forms General How can we navigate fron one form to other form...

Rong-Chun Zhang - MSFT

Hi Karun,

There are two situation of navigation between forms.

1) The two forms are in the same application, this is quite simple, we can call the Form.Show to navigate to the form we want.

2) The two forms are in different application, this is complex, we need to use windows API to achieve this. Check my sample below:

Code Block

namespace Win32P


public partial class Form3 : Form


public Form3()




/* The FindWindow function retrieves a handle to the top-level window whose class name and

* window name match the specified strings. This function does not search child windows.

* This function does not perform a case-sensitive search. To search child windows,

* beginning with a specified child window, use the FindWindowEx function. */

[DllImport("user32.dll", SetLastError = true)]

static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

// For Windows Mobile, replace user32.dll with coredll.dll


[return: MarshalAs(UnmanagedType.Bool)]

static extern bool SetForegroundWindow(IntPtr hWnd);


static extern IntPtr SetActiveWindow(IntPtr hWnd);

const int WM_SYSCOMMAND = 0x0112;

const int SC_MAXIMIZE = 0xF030;

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]

static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

private void button1_Click(object sender, EventArgs e)


//Find window(Microsoft Internet Explorer with blank page)

IntPtr hw = FindWindow("IEFrame", "Blank Page - Windows Internet Explorer");

//Active the window


//bring the window to front


//maximize the window

SendMessage(hw, WM_SYSCOMMAND, (IntPtr)SC_MAXIMIZE, IntPtr.Zero);




Hope this helps.
Best regards.
Rong-Chun Zhang