Share mdi and sdi in vb.net,

manhdinh920

New member
#MDI #SDI #vb.net #Windows Forms #Giao diện đa tài liệu

## MDI và SDI trong vb.net

** MDI ** và ** SDI ** là hai kiểu cửa sổ khác nhau cho các ứng dụng Windows Forms.MDI là viết tắt của ** Giao diện nhiều tài liệu ** và SDI là viết tắt của ** Giao diện tài liệu đơn **.Trong một ứng dụng MDI, tất cả các cửa sổ là cửa sổ con của một cửa sổ cha mẹ đơn lẻ.Điều này cho phép bạn dễ dàng chuyển đổi giữa các tài liệu khác nhau và chia sẻ dữ liệu giữa chúng.Trong một ứng dụng SDI, mỗi cửa sổ là một thể hiện riêng của ứng dụng.Điều này có nghĩa là mỗi cửa sổ có dữ liệu và cài đặt riêng và chúng không thể được chia sẻ giữa các Windows.

** vb.net ** cung cấp hỗ trợ cho cả ứng dụng MDI và SDI.Để tạo một ứng dụng MDI, bạn có thể sử dụng lớp `mdiapplication`.Để tạo ứng dụng SDI, bạn có thể sử dụng lớp `Ứng dụng`.

### Ứng dụng MDI

Để tạo ứng dụng MDI trong VB.NET, bạn có thể sử dụng các bước sau:

1. Tạo một dự án Windows Forms mới.
2. Trong ** Giải pháp Explorer **, nhấp chuột phải vào dự án và chọn ** Thêm **> ** Mục mới **.
3. Trong hộp thoại ** Thêm mục mới **, chọn ** Mẫu MDI ** và nhấp vào ** Thêm **.
4. Điều này sẽ tạo ra một hình thức mới gọi là `mdiform1`.
5. Trong nhà thiết kế `mdiform1`, thêm điều khiển` menustrip` vào biểu mẫu.
6. Trong điều khiển `Menustrip`, thêm một mục menu mới có tên ** Tệp **.
7. Trong mục ** tệp **, thêm một mục menu mới có tên ** Mới **.
8. Nhấp đúp vào mục menu `new` để tạo trình xử lý sự kiện mới.
9. Trong trình xử lý sự kiện, thêm mã sau:

`` `VBNet
Sub Mdiform1_New ()
'Tạo một hình thức trẻ mới.
Dim Childform là Mẫu mới1

'Thêm mẫu trẻ vào mẫu phụ huynh MDI.
Mdichildren.ADD (Trẻ em)

'Hiển thị hình thức trẻ em.
Childform.show ()
Kết thúc phụ
`` `

10. Chạy ứng dụng.

Khi bạn chạy ứng dụng, bạn sẽ thấy một mẫu phụ huynh MDI duy nhất.Khi bạn nhấp vào mục menu ** mới **, một biểu mẫu con mới sẽ được tạo và thêm vào biểu mẫu cha mẹ MDI.Sau đó, bạn có thể chuyển đổi giữa các biểu mẫu con khác nhau bằng cách nhấp vào các tab của chúng ở dạng cha mẹ MDI.

### Ứng dụng SDI

Để tạo ứng dụng SDI trong VB.NET, bạn có thể sử dụng các bước sau:

1. Tạo một dự án Windows Forms mới.
2. Trong ** Giải pháp Explorer **, nhấp chuột phải vào dự án và chọn ** Thêm **> ** Mục mới **.
3. Trong hộp thoại ** Thêm mục mới **, chọn ** Mẫu ** và nhấp vào ** Thêm **.
4. Điều này sẽ tạo ra một biểu mẫu mới gọi là `form1`.
5. Trong nhà thiết kế `form1`, thêm điều khiển` menustrip` vào biểu mẫu.
6. Trong điều khiển `Menustrip`, thêm một mục menu mới có tên ** Tệp **.
7. Trong mục ** tệp **, thêm một mục menu mới có tên ** Mới **.
8. Nhấp đúp vào mục menu `new` để tạo trình xử lý sự kiện mới.
9. Trong trình xử lý sự kiện, thêm mã sau:

`` `VBNet
Sub Form1_New ()
'Tạo một biểu mẫu mới.
Dim Newform dưới dạng Mẫu1 mới

'Hiển thị hình thức mới.
newform.show ()
Kết thúc phụ
`` `

10. Chạy ứng dụng.

Khi bạn chạy ứng dụng, bạn sẽ thấy một biểu mẫu SDI duy nhất.Khi bạn nhấp vào mục menu ** mới **, một biểu mẫu SDI mới sẽ được tạo và hiển thị.Sau đó, bạn có thể chuyển đổi giữa các biểu mẫu SDI khác nhau bằng cách nhấp vào biểu tượng thanh tác vụ của họ.

## hashtags

* #MDI
* #SDI
* #vb.net
* #Windows Forms
* #Giao diện đa tài liệu
=======================================
#MDI #SDI #vb.net #Windows Forms #Multi-Document Interface

## MDI and SDI in VB.NET

**MDI** and **SDI** are two different windowing styles for Windows Forms applications. MDI stands for **multiple document interface**, and SDI stands for **single document interface**. In an MDI application, all of the windows are child windows of a single parent window. This allows you to easily switch between different documents and to share data between them. In an SDI application, each window is a separate instance of the application. This means that each window has its own data and settings, and they cannot be shared between windows.

**VB.NET** provides support for both MDI and SDI applications. To create an MDI application, you can use the `MdiApplication` class. To create an SDI application, you can use the `Application` class.

### MDI Applications

To create an MDI application in VB.NET, you can use the following steps:

1. Create a new Windows Forms project.
2. In the **Solution Explorer**, right-click on the project and select **Add** > **New Item**.
3. In the **Add New Item** dialog box, select **MDI Form** and click **Add**.
4. This will create a new form called `MdiForm1`.
5. In the `MdiForm1` designer, add a `MenuStrip` control to the form.
6. In the `MenuStrip` control, add a new menu item called **File**.
7. In the **File** menu item, add a new menu item called **New**.
8. Double-click on the `New` menu item to create a new event handler.
9. In the event handler, add the following code:

```vbnet
Private Sub MdiForm1_New()
' Create a new child form.
Dim childForm As New Form1

' Add the child form to the MDI parent form.
MdiChildren.Add(childForm)

' Show the child form.
childForm.Show()
End Sub
```

10. Run the application.

When you run the application, you will see a single MDI parent form. When you click on the **New** menu item, a new child form will be created and added to the MDI parent form. You can then switch between the different child forms by clicking on their tabs in the MDI parent form.

### SDI Applications

To create an SDI application in VB.NET, you can use the following steps:

1. Create a new Windows Forms project.
2. In the **Solution Explorer**, right-click on the project and select **Add** > **New Item**.
3. In the **Add New Item** dialog box, select **Form** and click **Add**.
4. This will create a new form called `Form1`.
5. In the `Form1` designer, add a `MenuStrip` control to the form.
6. In the `MenuStrip` control, add a new menu item called **File**.
7. In the **File** menu item, add a new menu item called **New**.
8. Double-click on the `New` menu item to create a new event handler.
9. In the event handler, add the following code:

```vbnet
Private Sub Form1_New()
' Create a new form.
Dim newForm As New Form1

' Show the new form.
newForm.Show()
End Sub
```

10. Run the application.

When you run the application, you will see a single SDI form. When you click on the **New** menu item, a new SDI form will be created and shown. You can then switch between the different SDI forms by clicking on their taskbar icons.

## Hashtags

* #MDI
* #SDI
* #vb.net
* #Windows Forms
* #Multi-Document Interface
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top