Zdravim
Nespolupracuju mi dva subory vid nizsie. Chcem aby sa mi po kliknuti na menu vo formulari Okno.cs otvoril formular Okenko.cs. Vypisuje mi to chybu v prilohe na obrazku.
Diki za info
//Okno.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DvěOkna
{
public class Okno : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Okno()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3,
this.menuItem4});
this.menuItem1.Text = "Soubor";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Nové okno";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.Text = "-";
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.Text = "Konec";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// Okno
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 181);
this.Menu = this.mainMenu1;
this.Name = "Okno";
this.Text = "Hlavní okno";
}
[STAThread]
static void Main()
{
Application.Run(new Okno());
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
Close();
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Okénko špehýrka = new Okénko();
špehýrka.Show();
}
}
}
//Okenko.cs
// Pomocné okno
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace DvěOkna
{
public class Okénko : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
public Okénko()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 64);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Něco dělej";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Okénko
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 141);
this.Controls.Add(this.button1);
this.Name = "Okénko";
this.Text = "Okénko";
this.ResumeLayout(false);
}
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(this, "Flákám se", "Nšco dělám", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}