TAILIEUCHUNG - Ivor Horton’s Beginning Visual C++ 2005 phần 10

Bạn có nhiều hơn một kiểm soát trong hộp thoại mà bạn có thể sử dụng để cho phép một giá trị giới hạn được nhập vào. Bạn có thể sử dụng một điều khiển ListBox để cho phép người dùng lựa chọn từ một danh sách các giá trị có thể, vì vậy bạn có thể thử điều đó ở đây. Bạn nên bổ sung thêm hai điều khiển Label | Chapter 21 You have more than one control in the dialog box that you could use to permit a limit value to be entered. You can use a ListBox control to enable the user to select from a list of possible values so you can try that here. You should add two Label controls to the dialog box form with two ListBox controls alongside as shown in Figure 21-21. Figure 21-21 The Name property for the list boxes should be lottoLowerList and lottoUpperList for the top and bottom. As you see I resized the ListBox controls to be the same height as the Label controls and a width sufficient to display a single limit value. I also changed the font Size property to 10 and the ScrollAlwaysVisible property to True. Make sure the SelectionMode property value is One for both list boxes as you want to allow only one item to be selected from a list box at one time. The GUI for the dialog box is complete but to make it do what you want you are back in coding mode again. You can start with the code that populates the ListBox controls with limit values. Adding a List to a ListBox The list that a ListBoxcontrols is a set of objects that are stored as handles of type Object - so any kind of object can be stored in the list. In the example you want to store a set of integer limit values in each list box and for the most part you are able to rely on autoboxing and unboxing to convert values of type int to and from objects of type Int32 whenever necessary. The Items property for a ListBox object returns a reference to a collection of the objects in the list box this collection has an Add method that adds an object that you pass as the argument to the list. A ListBox object has a large number of properties including the Enabled property that has the value true when the user can interact with the list box and the value false when interaction is to be inhibited. The basic process for loading up the list for a list box is the same for both ListBox controls so you could code a private function member of

TÀI LIỆU MỚI ĐĂNG
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.