Use C # To create a 10 thousand sequence

Source: Internet
Author: User

In this article, we will use Microsoft's latest. Net Framework-C # To create a 10 thousand notebook (the program used in this article is a notebook with Calendar function ).

Start Microsoft VS. NET (Visual Studio. NET) to create a new project. Select the Visual C # project, select a Windows application in the template, and press "OK" to create a Windows form. This is what we usually call Win Form.

The style of the notebook is designed on the Visual C # interface. The 20 thousand keys control is required, a "Rich Text Box" (richtextbox Control) used to display, add, and edit the diary content, and a button used to add and modify the diary ). The richtextbox Control and the button control can be easily found in the toolbox. You don't need to add them any more. The key is perpetual calendar. We don't have to write 10 thousand RMB on our own, microsoft has already written for us. All you need to do is take it out and use it in the correct way. First, let me talk about how to call this perpetual calendar. It is a control provided by Microsoft VS. NET products. We are in. in the. NET window, click the "project" drop-down menu and select "Add/reference" to bring up a form for referencing controls. This form contains three tags, namely ". net, COM, and project ". The calendar control we want to use is included in "COM. Click it, and then after the hard disk burst, you will find many more controls. Find the Control Microsoft Calendar Control 9.0.

Select the control and click the selection button on the right. The control name will appear in the "selected components" window below. At this time, select the "OK" button below, the selected control is added to the project you created. You can find a widget named MonthCalendar and a widget named DateTimePicker in your toolbox. These two controls are just referenced. Here we will use the first MonthCalendar. Select the MonthCalendar control and draw its outline on the form. You can see that 10 thousand million bytes is displayed in front of us.

But we can only see it. In order to view or modify the previous diary, we also need to let the program know the date we selected in this control, so that we can tell the database, the date of the call. For the convenience of temporarily Using richtextbox to display the current date container.

Now let's take a look at how to make richtextbox display the date selected by MounthCalendar. Double-click the MounthCalendar control to go to the code page and get an event automatically created by the system. This event is the date selection event, which is the default event of the MounthCalendar control.

Private void monthCalendar_DateChanged (object sender,
System. Windows. Forms. DateRangeEventArgs e)
{
File: // thingCode executed after a trigger
}

With this event, we can let the program know when the user selects a new date. However, if you want to let the program know the date selected by the user and let the program display the date of the day on richtextbox, we still have a problem, that is, how to read the date selected by the user, which requires the following attribute

MonthCalendar. SelectionRange. Start. tow.datestring ().

The value of this attribute is the date selected by the user. Now that the event is defined and the attribute is also found, let's take a look at how to display the date in the richtextbox container.

Add this code to the event
RichTextBox. Text = monthCalendar. SelectionRange. Start. tow.datestring ();

Run it. After a date is selected, the date is displayed in richtextbox.

In this way, 10 thousand bytes is complete. From this example, we can see that VS. NET provides a wealth of control libraries. Do not waste these resources when using VS. NET for programming. They will help us save a lot of valuable time and energy.

Related Article

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.