***** Programmer *****
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
***** 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
Dùng Button trong c# EmptyWed Oct 24, 2012 5:28 am by quangvuspkt

» Bai tap Java can ban (Phan III )
Dùng Button trong c# EmptySat Sep 15, 2012 4:11 am by tsuyngam

» Bai tap Java can ban (Phan I )
Dùng Button trong c# EmptySat Sep 15, 2012 4:08 am by tsuyngam

» Một số bài tập C# căn bản
Dùng Button trong c# EmptyThu Dec 15, 2011 1:58 pm by nguyenhoduykhang

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

» My First Browser Tree Program in VB.NET
Dùng Button trong c# EmptyFri Aug 12, 2011 5:50 pm by kimthaohg85

» Giúp em bài C++ này với
Dùng Button trong c# EmptySun Jul 31, 2011 12:19 pm by kubin

» GIUP DO XAY DUNG BO GO TIENG VIET CODE C#
Dùng Button trong c# EmptySun Jul 24, 2011 8:40 pm by phonui82

» CHÀO TẤT CẢ CÁC THÀNH VIÊN TRONG DIỄN ĐÀN
Dùng Button trong c# EmptyTue Jul 19, 2011 9:28 am by phonui82

Đăng Nhập

Quên mật khẩu



April 2024
MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930     

Calendar Calendar


You are not connected. Please login or register

Dùng Button trong c#

Go down  Thông điệp [Trang 1 trong tổng số 1 trang]

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

Tesulakata

Tesulakata
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.

https://programmer.4umer.com

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