Click here to Skip to main content
15,902,635 members
Home / Discussions / C#
   

C#

 
QuestionOverriding custom contol OnPaint Pin
hpjchobbes5-Jul-08 6:54
hpjchobbes5-Jul-08 6:54 
AnswerRe: Overriding custom contol OnPaint Pin
Lutosław5-Jul-08 10:14
Lutosław5-Jul-08 10:14 
QuestionMDI Parent and Child Pin
benjamin yap5-Jul-08 5:27
benjamin yap5-Jul-08 5:27 
AnswerRe: MDI Parent and Child Pin
hpjchobbes5-Jul-08 8:04
hpjchobbes5-Jul-08 8:04 
GeneralRe: MDI Parent and Child [modified] Pin
benjamin yap6-Jul-08 0:08
benjamin yap6-Jul-08 0:08 
GeneralRe: MDI Parent and Child Pin
DaveyM696-Jul-08 1:33
professionalDaveyM696-Jul-08 1:33 
GeneralRe: MDI Parent and Child [modified] Pin
benjamin yap6-Jul-08 1:38
benjamin yap6-Jul-08 1:38 
GeneralRe: MDI Parent and Child Pin
DaveyM696-Jul-08 1:59
professionalDaveyM696-Jul-08 1:59 
There's plenty of examples around - I've coded up a quick one below (needs much improvement but a starter).

frmMain:
using System;
using System.Windows.Forms;

namespace EventSample
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Shown(object sender, EventArgs e)
        {
            frmLogin loginForm = new frmLogin();
            loginForm.StaffLogin += new OnStaffLogin(loginForm_StaffLogin);
            loginForm.ShowDialog();
            loginForm.Dispose();
        }

        void loginForm_StaffLogin(object sender, LogInEventArgs e)
        {
            MessageBox.Show("Staff logged in: " + e.Staff.Name);
        }
    }
    public class Staff
    {
        private string m_Name;
        public string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }
        public Staff(string name)
        {
            m_Name = name;
        }
    }
}

frmLogin (with button1 added):
using System;
using System.Windows.Forms;

namespace EventSample
{
    public delegate void OnStaffLogin(object sender, LogInEventArgs e);
    public partial class frmLogin : Form
    {
        public event OnStaffLogin StaffLogin;
        public frmLogin()
        {
            InitializeComponent();
        }
        private void FireStaffLogin()
        {
            StaffLogin(this, new LogInEventArgs(new Staff("Staff name goes here!")));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (StaffLogin != null)
            {
                FireStaffLogin();
            }
            Close();
        }
    }
    public class LogInEventArgs : EventArgs
    {
        private Staff m_Staff;
        public Staff Staff
        {
            get { return m_Staff; }
            set { m_Staff = value; }
        }
        public LogInEventArgs(Staff staff)
        {
            m_Staff = staff;
        }
    }
}


Dave

GeneralRe: MDI Parent and Child Pin
benjamin yap6-Jul-08 2:07
benjamin yap6-Jul-08 2:07 
GeneralRe: MDI Parent and Child Pin
DaveyM696-Jul-08 2:18
professionalDaveyM696-Jul-08 2:18 
GeneralRe: MDI Parent and Child [modified] Pin
DaveyM696-Jul-08 4:16
professionalDaveyM696-Jul-08 4:16 
GeneralRe: MDI Parent and Child [modified] Pin
benjamin yap6-Jul-08 4:48
benjamin yap6-Jul-08 4:48 
GeneralRe: MDI Parent and Child Pin
DaveyM696-Jul-08 5:45
professionalDaveyM696-Jul-08 5:45 
GeneralRe: MDI Parent and Child [modified] Pin
benjamin yap6-Jul-08 6:00
benjamin yap6-Jul-08 6:00 
GeneralRe: MDI Parent and Child Pin
DaveyM696-Jul-08 8:12
professionalDaveyM696-Jul-08 8:12 
GeneralRe: MDI Parent and Child Pin
DaveyM696-Jul-08 9:22
professionalDaveyM696-Jul-08 9:22 
GeneralRe: MDI Parent and Child Pin
benjamin yap6-Jul-08 15:30
benjamin yap6-Jul-08 15:30 
GeneralRe: MDI Parent and Child Pin
DaveyM697-Jul-08 11:29
professionalDaveyM697-Jul-08 11:29 
GeneralRe: MDI Parent and Child Pin
benjamin yap7-Jul-08 22:35
benjamin yap7-Jul-08 22:35 
QuestionBound combobox problem Pin
Alessandra775-Jul-08 4:38
Alessandra775-Jul-08 4:38 
QuestionHow to get a RGB values from an image buffer? Pin
CopperCircle5-Jul-08 2:58
CopperCircle5-Jul-08 2:58 
AnswerRe: How to get a RGB values from an image buffer? Pin
User 66585-Jul-08 3:07
User 66585-Jul-08 3:07 
AnswerRe: How to get a RGB values from an image buffer? Pin
Guffa5-Jul-08 5:47
Guffa5-Jul-08 5:47 
QuestionCreating DataView filter ... Pin
Jammer5-Jul-08 2:52
Jammer5-Jul-08 2:52 
Questionsetup problem for windows application Pin
K V Sekhar5-Jul-08 1:51
K V Sekhar5-Jul-08 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.