C # obtain the check information in the custom control in the main form

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.