icons

Getting Started with Windows Forms Designer in .NET Core

iFour Team - December 11, 2020

Listening is fun too.

Straighten your back and cherish with coffee - PLAY !

  •  
  •  
  •  
Getting Started with Windows Forms Designer in .NET Core
Table of Content

The new featureWindows Forms Designer is now available with the .NET Core which is released in Nov 2020. It is used in the .NET Framework but now we can use it in the .NET Core by just enable this tool from the Tools option of the visual studio.

It is available with visual studio’s latest version 2019 and preview version of it.

What is Windows Forms Designer?

Windows Forms Designer in the visual studio provides a quick development solution for creating the Windows Form based application. With this tool, we can easily add the controls, manipulate them, arrange them, and easily code for their event handle.

Using Windows Forms, we can build a rich and interactive user interface, display and manipulate data, and deploy apps to client computers.

Functionality

Using Windows Forms Designer, we can use:

1. Data control, add component, and windows-based controls to a form.

2. Double-click on the form and write the code in the load event for that form.

3. Edit control’s property by selecting the control and edit its property.

4. We can drag and drop the control using the mouse and place it wherever we want.

5. We can place our controls using short keys. Adjust the placement using ctrl + click , and adjust the control’s size using the Shift + click.

Example:

Step 1: How to Create Project

Let’s see how it works. First, open the visual studio 2019 and create the new project Windows Form App (.NET Core).

Open the project and you will see something like this below-attached snap.

If you will get some error according to the project then you can use the .NET Framework based windows forms or just try to reload the project in the solution explorer. Windows Forms will take some time to load.

Now let’s have a look how it looks like when we create the project.

Blog

Figure 1.0 Created Project

As we can see in the above figure, there is a form1.cs file which displays the design of the form in which we can add controls.

Step 2: Create Simple Form

First in this form, Drag and drop the controls like ‘Label’, ‘TextBox’, and ‘Button’ to create the simple registration form as below snap.

Blog

Figure 2.0 Registration Form

Here on the left side, we can see the tool box from which we will add control, and on the right side is the property of the controls from which we will change its properties.

Step 3: Event Handler (On button click)

Now after double click on the button, we will redirect to the ‘button1_Click’ in the form1.cs file. On button click event show the message using the ‘MessageBox.Show()’ property. We have attached the code below.

usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespaceWindowsFormsDesignerApp { publicpartialclassForm1 : Form { publicForm1() { InitializeComponent(); } privatevoid Form1_Load(object sender, EventArgs e) { } privatevoid button1_Click(object sender, EventArgs e) { MessageBox.Show("Successfully Registered"); } } }
Blog

Figure 3.0 Output

Project will run the forms according to the program.cs file.

namespaceWindowsFormsDesignerApp { staticclassProgram { ///
                    /// The main entry point for the application. ///
                    [STAThread] staticvoidMain() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }

We have applied here the STAThread attribute to specify that our windows forms application is a single-threaded apartment. To apply operating system styles to our forms add ‘EnableVisualStyles()’.

Searching for Dedicated ASP.Net Core Web Developer Your Search ends here.

We can view the form and customize it. Like give the background color, image, and opacity, and many more properties are there. Something like this:

Blog

Figure 4.0 Customize Windows Form

In this preview version of the windows forms, designers in the .NET Core is limited. This means it supports minimum numbers of the controls and properties. It will be more functional and supports more features in the next version.

Supported controls in preview 1 is:

  • Pointer

  • Button

  • Label

  • CheckBox

  • CheckedListBox

  • ComboBox

  • DateTimePicker

  • LinkLabel

  • ListBox

  • ListView

  • MaskedTextBox

  • MonthCalendar

  • NumericUpDown

  • PictureBox

  • ProgressBar

  • RadioButton

  • RichTextBox

  • TextBox

  • TreeView

Advantages of Windows Forms Designer

With the windows form designer, we can develop smart clients which means it is easy to deploy and update, we can work on it with the internet and without the internet, and can access the local resources in a more secure manner.

We can build a more attractive UI using a windows forms designer because of the drag and drop controls. And we can place it wherever we want to make UI better in the form. So, we can build rich, and interactive UI.

Other applications display the data from the database, XML file, and other data sources. But in windows forms, there is one flexible control called DataGridView. In which each and every data displayed in tabular forms. To bind data from the database, windows forms introduce the BindingSource which represents the connection to the data source, editing data source, and save changes, etc.

After all of this, we must send this application to the user. So, the user can run it on its own computer. In windows forms there is ClickOnce technology manages all the elements and dependencies in our application and makes sure that the application is correctly installed.

There are many other features in windows forms designer that make implementing common tasks easy. Such as creating a dialog box, and supports localization. Using localization, we can use this form to display in a different language.

Conclusion

Visual studio provides the windows forms to the .NET framework earlier, but now visual studio also provides the windows forms to the .NET core released recently. As we have seen in this blog, how windows forms are helpful in .NET core. Windows forms provide the fast and easy development of any application. Because it offers the drag and drops functionality and event handling with just a double click.We can also build windows form using the command line interface. Hope you acquired a detail understanding of windows forms designer in .NET Core.

Technology Stacks

Technology that meets your business requirements

Planning a cutting-edge technology software solution? Our team can assist you to handle any technology challenge. Our custom software development team has great expertise in most emerging technologies. At iFour, our major concern is towards driving acute flexibility in your custom software development. For the entire software development life-cycle, we implement any type of workflow requested by the client. We also provide a set of distinct flexible engagement models for our clients to select the most optimal solution for their business. We assist our customers to get the required edge that is needed to take their present business to next level by delivering various out-reaching technologies.

Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo
Logo

Our Global Presence

Get advanced technology that will help you find the
right answers for your every business need.

Get in touch

Need a Consultation?

Drop us a line! We are here to answer your questions 24/7.