- [C#] Hướng dẫn viết ứng dụng theo dõi máy in bao nhiêu trang (Monitor Printer)
- [C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
- [C#] Chia sẽ class Install, Uninstall, Start và Stop Services Winform
- [C#] Tìm kiếm tập tin file nhanh chóng trên Winform sử dụng thư viện FastSearchLibrary
- [C#] Giới thiệu thư viện Fluent FTP Awesome dùng để làm việc với FTP
- [C#] Sử dụng thư viện Mini Profiler Integrations ghi log thực hiện các câu lệnh SQL
- [DEVEXPRESS] Thiết kế Dropdown ButtonBarItem trên Form Ribbon
- [C#] Lưu trạng thái các control trên Winform vào Registry Windows
- [C#] Ứng dụng ví dụ Simple Observer Pattern tăng giảm số lượng trên winform
- [C#] Hướng dẫn lấy thời gian thực server time trên winform
- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
Viết chương trình MS paint đơn giản.
Hôm nay, mình xin hướng dẫn các bạn viết một chương trình ms paint đơn giản, ở đây ta cần 1 picturebox, (panel để vẽ hình lên) và các button dùng để thay đổi màu sắc,
- Ở đây chúng ta dùng sự kiện mouse move để vẽ là chính.
Code tham khảo ở dưới đây:
Dim down = False
Dim mybrush = Brushes.Black
Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
down = True
End Sub
Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
If down = True Then
PictureBox1.CreateGraphics.FillEllipse(mybrush, e.X, e.Y, 15, 15)
End If
End Sub
Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
down = False
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
mybrush = Brushes.Yellow
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
mybrush = Brushes.Red
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
mybrush = Brushes.Blue
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
mybrush = Brushes.Green
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
mybrush = Brushes.Purple
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
mybrush = Brushes.Pink
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
mybrush = Brushes.Brown
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
mybrush = Brushes.Orange
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
mybrush = Brushes.Black
End Sub
Chúc các bạn thành công!