Đang chuẩn bị liên kết để tải về tài liệu:
Week 2 - Windows Controls

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

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 (p.23+ p.30+ p.137+ p.172) Sharing event handler (p.167) ImageList component (p.115) ListView control (p.98) Slide 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 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 Module 2, bài 3: TextBox txt = new TextBox(); txt.Text = ""; txt.Name = "txt1"; txt.Location = new Point(20,20); txt.Width = groupBox1.Size.Width - 40; groupBox1.Controls.Add(txt); 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 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) { } this.textBox1.DoubleClick += new System.EventHandler(this.textBox1_DoubleClick); this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); 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 Exercise 2 – Module 3: private void radioButton_CheckedChanged(object sender, EventArgs e) { . | 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 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 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 Module 2, bài 3: TextBox txt = new TextBox(); txt.Text = ""; txt.Name = "txt1"; txt.Location = new Point(20,20); txt.Width = groupBox1.Size.Width - 40; groupBox1.Controls.Add(txt); Creating event handlers at run-time (p.172) Steps: Create a method

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