Custom Control calenderad, which contains three textbox txtyear, txtmonth, and txtyear;
1. Define two string variables errmessage and oprmessage in the custom control to save information;
When the textbox in calenderad is keypress, errmessage and oprmessage obtain relevant information;
2. Add an event to initializecomponent () in the main form:
This.calenderad.txt year. Enter + = new system. eventhandler (calenderad_getmessage );
This.calenderad.txt month. Enter + = new system. eventhandler (calenderad_getmessage );
This.calenderad.txt day. Enter + = new system. eventhandler (calenderad_getmessage );
This.calenderad.txt year. keypress + = new system. Windows. Forms. keypresseventhandler (calenderad_getmessage );
This.calenderad.txt month. keypress + = new system. Windows. Forms. keypresseventhandler (calenderad_getmessage );
This.calenderad.txt day. keypress + = new system. Windows. Forms. keypresseventhandler (calenderad_getmessage );
Add method in CSCalenderad_getmessage
Private void calenderad_getmessage (Object sender, eventargs E)
{
This. lblerrmessage. Text = calenderad. errmessage;
This. lblopermessage. Text = calenderad. opermessage;
}
In this way, when you press the button in txtyear, the form can obtain the desired prompt information.