1. Trang chủ
  2. » Giáo án - Bài giảng

Chapter 11 Advanced Topics in Windows Forms

14 288 0
Tài liệu đã được kiểm tra trùng lặp

Đ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

Thông tin cơ bản

Định dạng
Số trang 14
Dung lượng 157,28 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

11.1 Drag-Drop P523Source control Target control +MouseDown -TXT1.DoDragDrop textBox1.Text, DragDropEffects.Copy AllowDrop=true +DragEnter if e.Data.GetDataPresent DataFormats.Text e.E

Trang 1

Week 10

Chapter 11 Advanced Topics in

Windows Forms

Chapter 12 Enhancing Usability

Chapter 15: Crystal Report

Chapter 11 Advanced Topics

in Windows Forms

 11.1 Drag-Drop (P523)

 11.2 MDI (P543)

Trang 2

11.1 Drag-Drop (P523)

 Windows users fall into two general

categories:

 use the keyboard

 use the mouse

 Drag and drop: same as cutting and pasting

using keyboard

11.1 Drag-Drop (P523)

Sequence of events

 Dragging is initiated (call DoDragDrop for the source )

 The DoDragDrop method takes two parameters:

 data

 allowedEffects

 A new DataObject object is automatically created

 Raises the GiveFeedback event (display a custom

mouse pointer during the drag)

 Control with AllowDrop =True can receive drop.

 DragEnter raised (mouse pass).

Trang 3

11.1 Drag-Drop (P523)

Source control

Target control

+MouseDown

-TXT1.DoDragDrop

(textBox1.Text,

DragDropEffects.Copy )

AllowDrop=true

+DragEnter

if (e.Data.GetDataPresent (DataFormats.Text))

e.Effect = DragDropEffects.Copy;

+DragDrop

TXT2.Text = (string)e.Data.GetData ( DataFormats.Text);

Drag-Drop: demo: Textbox

 Using Textbox

 Step1: DragEnter event

 Step2: DragDrop event

 Step3: MouseDown event

Trang 4

Drag-Drop: demo: PictureBox

 AllowDrop

 DragEnter

 DragDrop

 KeyState

11.1 DragDrop (P523)

-demo: treeview

 Example: Drag-Drog in Treeview

 treeview1.PointToClient(new Point(e.X, e.Y));

 Clone node;

}

Trang 5

form tree

Xform

Yform

Xcontrol

Ycontrol

Point_form(Xform,Yform)

Point_control(Xform,Yform)

C PointToClient(Point_form )

11.1 DragDrop (P523)

-demo: Listview

 Make new collection

 Array

 ArrayList

 List<generic>

Trang 6

11.2 MDI

 parent form/child form model

 Has a single parent form

 The parent form organizes and

arranges all of the child documents that

are currently open.

11.2 MDI

 What is an MDI Form?

 Multiple-document interface (MDI)

applications allow you to display multiple

documents at the same time, with each

document displayed in its own window

Trang 7

11.2 MDI

 How do I create an MDI Parent form ?

 Creating an MDI Parent Form

 IsMDIContainer=true

 How do I create an MDI Child form ?

 Creating MDI Child Forms

 Set MdiParent to parent form

11.2 MDI

 How do I change the Background color of an MDI Parent form?

 private void MDIParent1_Load(object sender, EventArgs e)

 foreach (Control c in this.Controls) {

 MdiClient m = (MdiClient)c;

 m.BackColor = Color.Red;

Trang 8

11.2 MDI

 Identifying the Active Child Form

 Form aForm;

 aForm = this.ActiveMDIChild;

11.2 MDI

 Arranging MDI Child Forms

 this.LayoutMdi(System.Windows.Forms.Mdi

Layout.Cascade);

Trang 9

11.2 MDI

 Window List Menu

 MenuStrip component

 Set the MdiWindowListItem property to the

menu item

11.2 MDI

 How do I check if an MDI Child form already exists,

so that we don't show the same form twice?

 foreach (Form f in this.MdiChildren)

 if (f.Text == "Window 2")

 this.ActivateMdiChild(f);

Trang 10

Chapter 12 Enhancing

Usability

 Lesson 2: Using User Assistance

Controls and Components

 The ProgressBar Control

 StatusStrip Control

 ToolTip Component

 ErrorProvider Component

 HelpProvider Component

Chapter 12 Using User Assistance

Controls and Components

 The ProgressBar Control

 Visually indicate progress for a

time-consuming operation

 Maximum, Minimum, Value, Step

progressBar1.Minimum = 0;

progressBar1.Maximum = 100;

progressBar1.Step = 1;

Trang 11

Chapter 12 Using User Assistance

Controls and Components

 StatusStrip Control

 Display status information about the

application

 ToolStripStatusLabel

 Text

Chapter 12 Using User Assistance

Controls and Components

 ToolTip Component

 To set a tooltip in the Designer

 To set a tooltip in code

 toolTip1.SetToolTip(button1,

"This button activates the self-destruct

Trang 12

Chapter 12 Using User Assistance

Controls and Components

 ErrorProvider Component

 provide feedback to the user when an error

condition results for a control in the form

 Turn on

 errorProvider1.SetError(TextBox1, "Value must

be numeric");

 Turn off

 errorProvider1.SetError(TextBox1, "");

Chapter 15: Report

Trang 13

Chapter 15: Crystal Report

 Crystal Report File

 Crystal Report Viewer

Chapter 15: Crystal Report

 1 Create Type Dataset

 2 Create Crystal Report Template

 Menu Project -> Add new item -> Crystal Report

 ->Using Report Wizard->choose

Typed-Dataset->…

Trang 14

Chapter 15: Crystal Report

Typed Dataset

Dataset

Crystal Report.Rpt

Crystal Report Viewer

Class

Chapter 15: Crystal Report

 //Create and Fill data into Dataset ds



 CrystalReport1 c = new CrystalReport1();

 c.SetDataSource(ds);

 crystalReportViewer1.ReportSource = c;

Ngày đăng: 13/05/2014, 12:19

TỪ KHÓA LIÊN QUAN

w