CALCULADORA SIMPLES EM C# WINDOWS FORMS

Rogers
6 Oct 202107:35

Summary

TLDRThis tutorial guides users through creating a simple calculator in C# using Visual Studio 2019. The process begins with setting up a Windows Forms project, designing the user interface with labels, textboxes, and buttons for basic arithmetic operations. The script explains how to write the code to perform addition, subtraction, multiplication, and division, while demonstrating the use of event handlers for button clicks. With clear step-by-step instructions, the tutorial ensures that users can quickly build a working calculator application. The video concludes with the demonstration of the fully functional calculator.

Takeaways

  • 😀 The tutorial demonstrates how to create a simple calculator using C# in Visual Studio 2019.
  • 😀 The project is created as a Windows Forms Application with the .NET Framework 4.5.
  • 😀 The form’s properties are configured to disable the maximize button and set its name and title.
  • 😀 Essential controls like GroupBox, Labels, Textboxes, and Buttons are added for the calculator’s interface.
  • 😀 The TextBox controls are named appropriately for the two input numbers (txtNumero1 and txtNumero2).
  • 😀 The operation buttons (Sum, Subtract, Multiply, Divide) are added with corresponding names (btSomar, btSubtrair, btMultiplicar, btDividir).
  • 😀 A result Label is added at the bottom to display the calculation results, with its font size adjusted for visibility.
  • 😀 Event handlers are written for each operation button to handle the arithmetic logic.
  • 😀 The arithmetic operations (addition, subtraction, multiplication, and division) are performed by converting the input from TextBox (string) to float.
  • 😀 After performing the calculation, the result is converted back to a string and displayed in the result Label.
  • 😀 The tutorial shows the app in action, demonstrating the functionality of the four operations, ensuring the program works as expected.

Q & A

  • What is the main purpose of the project created in the script?

    -The main purpose is to create a simple calculator application using Windows Forms in C#.

  • Which version of Visual Studio is used in the script?

    -The script uses Visual Studio 2019 to create the Windows Forms project.

  • What framework version is used for the project?

    -The project uses .NET Framework 4.5.

  • Which UI container is added first to the form?

    -A GroupBox container is added first to organize the input fields and buttons.

  • What controls are used to input the numbers for the calculations?

    -Two labels and two text boxes are used to represent and receive the first and second number.

  • How many operation buttons are created and what are they?

    -Four buttons are created: Somar (Add), Subtrair (Subtract), Multiplicar (Multiply), and Dividir (Divide).

  • How is the result displayed in the application?

    -The result is displayed using a Label control that is updated with the computed value.

  • How are text values from the textboxes converted for calculation?

    -The text values are converted from string to float using `float.Parse()` before performing operations.

  • Why is `.ToString()` used after the calculation?

    -Because the label that displays the result expects a string, so the numeric calculation result must be converted back to string.

  • How is the event handler for each operation created?

    -Each event handler is automatically generated when the user double-clicks a button in the form designer.

  • What modification is made to the form to prevent resizing?

    -The MaximizeBox property is disabled so the window cannot be maximized.

  • How is code reused for operations besides addition?

    -The addition code is copied into the other button events, with only the arithmetic operator changed for each operation.

Outlines

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Mindmap

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Keywords

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Highlights

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Transcripts

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن
Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
C# TutorialVisual StudioCalculator AppWindows FormsProgrammingSoftware DevelopmentUI DesignBeginner GuideSimple CalculatorTech Tutorial
هل تحتاج إلى تلخيص باللغة الإنجليزية؟