Hello,
I'm trying to make an event that will close a usercontrol and open another one. The first user control is for login and when the password have been validated, the event should fire and the event/form would close the usercontrol. The problem is that the form can't see the event with the error "are you missing a using directive or an assembly reference?"
The form code:
	It's line 26 that gives me the error (OnMyEvent).
And the usercontrol:
	
							
						
					I'm trying to make an event that will close a usercontrol and open another one. The first user control is for login and when the password have been validated, the event should fire and the event/form would close the usercontrol. The problem is that the form can't see the event with the error "are you missing a using directive or an assembly reference?"
The form code:
Code:
	using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
namespace økonomi
{
    
    public partial class MainForm : Form
    {
        UserControl LoginControl = new LoginControl();
        public MainForm()
        {
            InitializeComponent();
            InitControl();
        }
        void InitControl()
        {
            LoginControl.OnMyEvent += new LoginControl.onMyEventHandler(catchevent);
            panel1.Controls.Add(LoginControl);
        }
        static void catchevent(object sender, EventArgs e)
        {
            MessageBox.Show("Hello");
        }
    }
}
And the usercontrol:
Code:
	using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace økonomi
{
    
    public partial class LoginControl : UserControl
    {
        public delegate void onMyEventHandler(object sender, EventArgs e);
        public event onMyEventHandler OnMyEvent;
        
        public LoginControl()
        {
            InitializeComponent();
        }
        
        public void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtPwd.ToString() == "1234")
            {
                OnMyEvent(this, e);
            }
            
        }
    }
}
Comment