1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài giảng Lập trình trên môi trường Windows: Phần 1 - Windows control

31 7 0

Đ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

Tiêu đề Windows Control
Tác giả Trần Duy Hoàng
Trường học Hồ Chí Minh University of Science
Chuyên ngành Computer Science
Thể loại Bài giảng
Thành phố Hồ Chí Minh
Định dạng
Số trang 31
Dung lượng 158,75 KB

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

Nội dung

Phần 1 Windows control trong bài giảng Lập trình trên môi trường Windows cung cấp cho các bạn những kiến thức về Form, TextBox, CompoBox, thuộc tính, hàm chung, Dialog thông dụng. Với các bạn chuyên ngành Công nghệ thông tin thì đây là tài liệu tham khảo hữu ích.

Trang 1

L p trình trên môi tr ậ ườ ng Windows

Windows control - Ph n 1 ầ

Tr n Duy Hoàng ầ

tdhoang@hcmus.edu.vn

Trang 3

Form

Trang 8

private void DemoForm_Load(object sender, EventArgs e){

this.Text = "Demo";

this.Size = new Size(500, 500);

this.BackgroundImage = new Bitmap("background.jpg"); this.Opacity = 0.75;

Trang 9

Form

Trang 10

● Ch a danh sách các control con c a nó ứ ủ

● Thêm xóa đ ng các control vào form ộ

Button btn = new Button;

btn.Text = “Hello”;

btn.Size = new Size (50, 50);

btn.Location = new Point (10,10);

this.Controls.Add(btn);

Trang 11

this.ClientSize = new Size(500, 500);

Button[,] arrButton = new Button[10, 10];

for (int i = 0; i < 10; i++) {

for (int j = 0; j < 10; j++) {

arrButton[i,j] = new Button();

arrButton[i,j].Size = new Size(50, 50);

arrButton[i,j].Location = new Point(j * 50, i * 50); this.Controls.Add(arrButton[i,j]);

}

}

Trang 12

Form

Trang 16

● KeyDown(), KeyUp()

➢ if (e.KeyCode == Keys.F5) { ThemNhanVien();

e.Handled = true;}

➢ if (e.KeyCode == Keys.N && e.Control == true) { ThemNhanVien();

e.Handled = true;

Trang 20

● Validating() / Validated()

● TextChange

Trang 24

● SelectedIndexChanged

● SelectedValueChanged

Trang 25

}

Trang 26

Dialog thông d ng ụ

OpenFileDialog dialog = new OpenFileDialog();

dialog.InitialDirectory = Application.ExecutablePath; dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; dialog.FilterIndex = 2;

dialog.RestoreDirectory = true;

if (dialog.ShowDialog() == DialogResult.OK)

{

Trang 27

Dialog thông d ng ụ

SaveFileDialog dialog = new SaveFileDialog();

dialog.InitialDirectory = Application.ExecutablePath; dialog.Filter = "txt files (*.txt)|*.txt";

Trang 28

Dialog thông d ng ụ

FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.RootFolder = Environment.SpecialFolder.Desktop; dialog.ShowNewFolderButton = true;

if (dialog.ShowDialog() == DialogResult.OK)

{

MessageBox.Show(dialog.SelectedPath);

}

Trang 29

Dialog thông d ng ụ

Trang 30

Dialog thông d ng ụ

Trang 31

Tr n Duy Hoàng - tdhoang@fit.hcmus.edu.vn ầ

Th o lu n ả ậ

Ngày đăng: 08/05/2021, 11:55

TỪ KHÓA LIÊN QUAN