Simple windows forms
Windows Forms is a graphical user interface (GUI) framework provided by Microsoft that allows developers to create desktop applications for Windows using the .NET Framework. It provides a set of controls and tools for creating user interfaces, such as buttons, text boxes, labels, and menus.
Here's an example of a simple Windows Forms application using C# in Visual Studio:
Open Visual Studio and create a new Windows Forms project. To do this, select "File" -> "New" -> "Project" from the menu bar, then choose "Windows Forms App (.NET Framework)" under the Visual C# category.
Once the project is created, open the form designer by double-clicking on the Form1.cs file in the Solution Explorer.
In the designer, add some controls to the form. For example, you could add a Label control and a Button control by selecting them from the Toolbox and dragging them onto the form.
In the Properties window, you can set various properties for each control. For example, you can set the text property of the Label control to "Hello, World!".
Double-click on the Button control to create an event handler for the Click event. This will generate a new method in your code that will be called when the button is clicked.
In the event handler method, you can write code to perform the desired action. For example, you could add code to change the text of the Label control to "Button clicked!".
Here's an example of what the code might look like:
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "Button clicked!";
}
Comments
Post a Comment