[Mono-list] How to add menu to Winform application

Andrus kobruleht2 at hot.ee
Mon Sep 11 14:33:40 EDT 2006


> Just make sure that the controls you use are 1.1 controls (none of the
> Toopstrip classes for example).

Thank you.
I created menu using MainMenu control.
When running application the error occurs:

Method not found: 'System.Windows.Forms.MainMenu..ctor'

What I'm doing wrong ?

Andrus.

Code to reproduce:

Program.cs:

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace WindowsApplication1

{

static class Program

{

[STAThread]

static void Main()

{

try

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);


Application.Run(new Form1());

}

catch (System.Exception exception)

{

ExceptionDisplay.ShowError(exception);

}

}

}

public class ExceptionDisplay

{

public static void ShowError(Exception e)

{

String str = "Message: " + e.Message + "\n" +

"Source: " + e.Source + "\n" +

"Help link: " + e.HelpLink + "\n" +

"Previous error: " + e.InnerException + "\n" +

"Method: " + e.TargetSite + "\n\n" +

"Stack trace: " + e.StackTrace;


System.Windows.Forms.MessageBox.Show(str, "Error",

MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

}




Form1.Designer.cs :



namespace WindowsApplication1

{

partial class Form1

{



private System.ComponentModel.IContainer components = null;



/// <param name="disposing">true if managed resources should be disposed; 
otherwise, false.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);

this.menuItem1 = new System.Windows.Forms.MenuItem();

this.menuItem2 = new System.Windows.Forms.MenuItem();

this.SuspendLayout();

//

// 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.menuItem1.Text = "test";

//

// menuItem2

//

this.menuItem2.Index = 0;

this.menuItem2.Text = "test1";

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(292, 273);

this.Menu = this.mainMenu1;

this.Name = "Form1";

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.MainMenu mainMenu1;

private System.Windows.Forms.MenuItem menuItem1;

private System.Windows.Forms.MenuItem menuItem2;

}

}



More information about the Mono-list mailing list