Jordi Mas wrote:
2: How do I bind a shortcut key to an action/function without using the
setting the shortcut key in MainMenu/ContextMenu? (Can not set menu in my current mono setup either. Always complains about set_Menu method, throwing a NullReferenceException)


Hello Wei,

Can you provide a small sample that reproduces this problem?

Thanks!


I have attached the small sample to this email. The environment is mono 1.1.6, OSX 10.3. I could mono the same program on fedora 2, however, the menu never really showed.



The error message I got is:

[EMAIL PROTECTED] TestMono]$ mono Test.exe
Mono System.Windows.Forms Assembly [Revision: 41731; built: 2005/2/15 5:56:12]
Keyboard: United States keyboard layout (phantom key version)

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
in <0x0007c> System.Windows.Forms.Form:set_Menu (System.Windows.Forms.MainMenu)
in <0x00084> (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:set_
Menu (System.Windows.Forms.MainMenu)
in <0x000d8> Form1:InitializeComponent ()
in <0x0006c> (wrapper remoting-invoke-with-check) Form1:InitializeComponent ()
in <0x00024> Form1:.ctor ()
in <0x00048> (wrapper remoting-invoke-with-check) Form1:.ctor ()
in <0x0002c> Form1:Main ()

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form
{
        private System.ComponentModel.Container components = null;

        public Form1()
        {
                InitializeComponent();
        }

        protected override void Dispose( bool disposing )
        {
                if( disposing )
                {
                        if (components != null) 
                        {
                                components.Dispose();
                        }
                }
                base.Dispose( disposing );
        }

        private void InitializeComponent()
        {
                MainMenu mBar = new MainMenu();

                MenuItem item1 = new MenuItem();

                item1.Text = "File";

                mBar.MenuItems.Add(item1);

                this.Menu = mBar;
                this.SuspendLayout();
                // 
                // Form1
                // 
                this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
                this.ClientSize = new System.Drawing.Size(316, 214);
                this.Name = "Form1";
                this.Text = "Form1";
                this.ResumeLayout(false);

        }

        static void Main() 
        {
                Application.Run(new Form1());
        }
}

Reply via email to