TAILIEUCHUNG - Week 2 - Windows Controls

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, ) | Week 2 Windows Controls (Chapter 1 - 4) Contents Adding control and event at run-time ( ) Sharing event handler () ImageList component () ListView control () Slide Adding control at run-time ( ) 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 Adding control at run-time: Example Button aButton = new Button(); = new Point(20,20); = "Test Button"; (aButton); // add button to form // (aButton); // add button to panel Exercise 3 – Module 3 Slide Module 2, bài 3: TextBox txt = new TextBox(); = ""; = "txt1"; = new Point(20,20); = - 40; (txt); Creating event handlers at run-time () 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 ) { ("aaaa"); } += new EventHandler(EventMethod); Remove an event handler by using the =- operator Slide Exercise 3 – Module 3 Exercise 3 – Module 3 private void textBox1_TextChanged(object sender, EventArgs e) { TextBox t=(TextBox)sender; } private void textBox1_DoubleClick(object sender, EventArgs e) { } += new (); += new (); Sharing event handler () 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 Exercise 2 – Module 3: private void radioButton_CheckedChanged(object sender, EventArgs e) { .

Đã 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.