***** Programmer *****

Học lập trình từ căn bản

Tìm kiếm
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Tuyên mộ thành viên
Wed Oct 24, 2012 5:28 am by quangvuspkt

» Bai tap Java can ban (Phan III )
Sat Sep 15, 2012 4:11 am by tsuyngam

» Bai tap Java can ban (Phan I )
Sat Sep 15, 2012 4:08 am by tsuyngam

» Một số bài tập C# căn bản
Thu Dec 15, 2011 1:58 pm by nguyenhoduykhang

» Xem thông tin máy tính bằng c#
Tue Nov 08, 2011 8:19 am by namcongtu288

» My First Browser Tree Program in VB.NET
Fri Aug 12, 2011 5:50 pm by kimthaohg85

» Giúp em bài C++ này với
Sun Jul 31, 2011 12:19 pm by kubin

» GIUP DO XAY DUNG BO GO TIENG VIET CODE C#
Sun Jul 24, 2011 8:40 pm by phonui82

» CHÀO TẤT CẢ CÁC THÀNH VIÊN TRONG DIỄN ĐÀN
Tue Jul 19, 2011 9:28 am by phonui82

Đăng Nhập

Quên mật khẩu



August 2017
MonTueWedThuFriSatSun
 123456
78910111213
14151617181920
21222324252627
28293031   

Calendar Calendar


You are not connected. Please login or register

Dùng Button trong c#

Xem chủ đề cũ hơn Xem chủ đề mới hơn Go down  Thông điệp [Trang 1 trong tổng số 1 trang]

1default Dùng Button trong c# on Tue Feb 16, 2010 9:32 pm

Tesulakata

avatar
Thành viên
Thành viên
How to: Use Button Controls

Buttons enable users to interact with your program. For example, many dialog boxes have an OK button and a Cancel button. Users can click the OK button to submit the information entered in the dialog box. Alternatively, they can click Cancel to close the dialog box without submitting any data.

You can set properties of a button to change its appearance. For example, you can set the Text property to display specific text on a button, or set the ForeColor property to change the color of the text. For more information, see How to: Create a Non-Rectangular Button.

Controls have events that are raised whenever a user performs a specific action on the control. You can create event handlers that determine how the program should respond to the event. All controls have a default event handler, and for a button, it is the Click event. The code that you write in the Click event handler of the button runs whenever the user clicks the button.


To use buttons in a program
On the File menu, click New Project.

In the New Project dialog box, in the Templates pane, click Windows Forms Application.

In the Name box, type ButtonExample, and then click OK.

A new Windows Forms project opens.

From the Toolbox, drag a Button onto the form.

In the Properties window, change the Text property to read: Display Date and then press ENTER.

In the Properties window, click the drop-down arrow to the right of the ForeColor property, and then click the Custom tab of the dialog box that opens.

Click the red box to apply red font to the text of the button.

In the form, double-click the button to open the Code Editor.

The Code Editor opens in the middle of a method named button1_Click. This is the Click event handler. The code you write here will execute when the button is clicked.

In the button1_Click event handler, type the following line of code.


Code:
MessageBox.Show("Today is " +
    DateTime.Today.ToLongDateString());



Press F5 to run your program.

The program starts and the form appears. When you click the Button, a message box displays today's date.

Xem lý lịch thành viên http://programmer.4umer.com

Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang  Thông điệp [Trang 1 trong tổng số 1 trang]

Permissions in this forum:
Bạn không có quyền trả lời bài viết