The file names are not case sensitive and the name of the form has nothing to do with the name of the form.
A .cs file could contains many forms defined and more that one classes but it is not recomended.
I think you have problem with the namespace.
I give you here an example like a "pattern" that you could use. Here is an example of a mainform (MainForm.cs file) and a LogonForm (LogonForm.cs) which is called from the main form when a menu item is clicked.
Take a look to:
-what to using ... in each file,
-how is declared the namespece in each file
-how the main form "knows" the second form . Note that is a way for the second form to knows the main form but is not shown in this code.
-how the MainForm class is instantiated in the Main() function .e.g. create an instance (object) of the MainForm class but not assigned to any variable.
-how the LogonForm is INSTANTIATED in the constructor of the main form e.g. create an object of a given type in this case of the LogonForm and store it in the member variable of the main form.
-how the LogonForm is shown using two ways: ShowDialog(), Show()
Code:
// MainForm.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace YourNameSpace
/// <summary>
/// Summary description for MDI.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
// other members
private LogonForm m_LogonForm;
private System.Windows.Forms.MenuItem m_MnuConnect; //menu connect
public MainForm()
{
InitializeComponent();
m_LogonForm= new LogonForm();
}
private void InitializeComponent()
{
// initialization code
}
private void m_MnuConnect_Click(object sender, System.EventArgs e)
{
//...
this.m_LogonForm.ShowDialog(); // as modal
// or
// this.m_LogonForm.Show();
}
static void Main()
{
Application.Run(new MainForm());
}
}
// LogonForm.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace YourNameSpace
{
/// <summary>
/// Summary description for LogonForm.
/// </summary>
public class LogonForm : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox m_TxtPassword;
private System.Windows.Forms.Label m_LblPassword;
private System.Windows.Forms.Label m_LblUserID;
}
//...
}
static void Main()
{
Application.Run(new MainForm());
}
-obislavu-