Mã nguồn system window form c
If your project includes Windows Forms, you can use JetBrains Rider's visual Windows Forms designer and also create new Windows Forms projects. You can create a new project in a new solution using or add a new project to the existing solution by right-clicking the
solution or solution folder node in the Solution Explorer, and choosing . Choose Desktop Application project template and then Desktop Application as the project type. You can add Windows Forms items in any project which have a reference to When you double-click a Windows Form item, it opens in a new editor tab and additionally opens the Designer Toolbox window. Press Shift+F7 to switch to the designer and
F7 to view
the source code. Use the Designer and Code tabs at the bottom of the editor. When working in the designer view, you can select the desired component in the Designer Toolbox and then without dragging it, draw a rectangle area on the canvas where the component should be added. If you decide not to add the component that you
clicked, click the Pointer item in the components view. Edit components on the canvas
By default, the Designer Toolbox window lists standard Windows Forms components. To add add custom components to the toolbox, click Manage Components and then select the desired components there. All components from Global Assembly Cache and installed NuGet packages will be available for selection automatically. To load component assemblies from disk, click Add in the left part of the dialog and pick the desired assembly.Last modified: 17 March 2022 1. Mở đầuĐể thực hiện bài viết hướng dẫn, mình sẽ tạo ra một ứng dụng dạng Windows Form App (.NET Framework) đơn giản trên Visual Studio. 2. Các bước thực hiện+ Đầu tiên, mình đã tạo ra 1 form có tên là MainForm và trong form sẽ có 1 button (btnOpenURL). Tạo một form đơn giản.+ Tiếp theo, mình sẽ tạo ra một sự kiện cho button đã tạo (btnOpenURL) như sau: private void btnOpenURL_Click(object sender, EventArgs e) { string url = "https://www.phanxuanchanh.com"; // URL cần được mở trên trình duyệt. Process.Start(url); // Thực hiện mở URL trên trình duyệt. } Sau khi thực hiện xong các bước trên, khi bạn chạy chương trình và nhấn vào button Mở URL (btnOpenURL) thì trình duyệt sẽ được mở và truy cập vào URL mà bạn đã chỉ định. Lưu ý: Việc mở URL trên trình duyệt nào sẽ phụ thuộc vào thiết lập của bạn, cụ thể là trình duyệt nào đang được thiết lập làm trình duyệt mặc định. * Toàn bộ code của form đã tạo (MainForm) + Phần code giao diện: namespace OpenURL { partial class MainForm { /// + Phần code xử lý: using System; using System.Diagnostics; using System.Windows.Forms; namespace OpenURL { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void btnOpenURL_Click(object sender, EventArgs e) { string url = "https://www.phanxuanchanh.com"; Process.Start(url); } } } 3. Các bài viết liên quanNếu các bạn quan tâm đến các bài viết về ngôn ngữ lập trình C# thì có thể đọc các bài viết sau đây:
4. Lời kếtThông qua bài viết này, mình đã thực hiện một chương trình siêu đơn giản, để từ đó, hướng dẫn bạn cách để thực hiện mở một URL trên trình duyệt trong Windows Form App (C#). Tóm lại, để mở URL trên trình duyệt thì chỉ cần sử dụng Process.Start(url). Quá đơn giản phải không nào? Cuối cùng, cảm ơn các bạn đã đọc bài viết, nếu các bạn có vấn đề cần giải đáp, hãy để lại bình luận cho mình nhé! Hits: 123 |