Windows Controls pdf

27 286 0
Windows Controls pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Week 2 Windows Controls (Chapter 1 - 4) Contents  Adding control and event at run-time (p.23+ p.30+ p.137+ p.172)  Sharing event handler (p.167)  ImageList component (p.115)  ListView control (p.98) Slide 2 Adding control at run-time (p.23+ p.30+ p.137)  Steps:  Instantiate a new control  Set some properties of the control  Name property  Location property  Text property  …  Add it to the Controls collection of the form or the container (GroupBox,Panel, FlowLayoutPanel,…) Slide 3 Adding control at run-time: Example Button aButton = new Button(); aButton.Location = new Point(20,20); aButton.Text = "Test Button"; this.Controls.Add(aButton); // add button to form // panel1.Controls.Add(aButton); // add button to panel Exercise 3 – Module 3 Slide 4 Creating event handlers at run- time (p.172)  Steps:  Create a method whose signature matches the signature for the event  Use the += operator to associate the method with the event  Example: private void EventMethod( object sender, EventArgs e ) { MessageBox.Show("aaaa"); } … aButton.Click += new EventHandler(EventMethod);  Remove an event handler by using the =- operator Slide 5 Exercise 3 – Module 3 Sharing event handler (p.167)  Sharing event handler for case: Multi-controls use the same event handler  At design-time:  See near figure  Exercise 2,6 – Module 3  At run-time:  Write code: use +=  Exercise 5 – Module 3 Slide 6 ImageList component (p.115)  ImageList is a component that allows you to organize groups of images  ImageList supplies images to other controls, such as ListView, TreeView control (p.116)  Some important properties:  Images  ImageSize  To access the images contained in the ImageList  PictureBox1.Image = ImageList1.Images[0];  Exercise 5 – Module 3 (rotate moon), at home Slide 8 ListView control (p.98) Column Header Items SubItems Use to displays list of items Slide 9 Properties of ListView control Slide 10 Properties Description Columns Contains the collection of columns to be displayed when the View property is set to Details FullRowSelect Indicating whether the user can select an entire row GridLines Indicating whether grid lines between items and subitems are drawn HideSelection Indicating whether the selected items to be hide when lost focus Properties of ListView control (cont.) Properties Description Items Contains a collection of ListViewItem objects MultiSelect Indicating whether the user can select multiple rows View Indicates the manner in which ListView items are displayed LargeImageList The ImageList component from which images for ListViewItems are drawn when the View property is set to LargeIcon or SmallIcon SmallImageList Slide 11 . Week 2 Windows Controls (Chapter 1 - 4) Contents  Adding control and event at run-time. Point(20,20); aButton.Text = "Test Button"; this .Controls. Add(aButton); // add button to form // panel1 .Controls. Add(aButton); // add button to panel Exercise

Ngày đăng: 15/03/2014, 02:20

Từ khóa liên quan

Mục lục

  • Week 2

  • Contents

  • Adding control at run-time (p.23+ p.30+ p.137)

  • Adding control at run-time: Example

  • Creating event handlers at run-time (p.172)

  • Sharing event handler (p.167)

  • ImageList component (p.115)

  • ListView control (p.98)

  • Properties of ListView control

  • Properties of ListView control (cont.)

  • Slide 12

  • Default event in ListView control

  • Methods, properties of ListView’s Items

  • Using image icon in ListView

  • Example ListView

  • Some operations with ListView control

  • Add item

  • Delete selected items

  • Edit selected item

  • Display selected item

Tài liệu cùng người dùng

Tài liệu liên quan