SelfTest-windows Form
SelfTest-windows Form
1. Create windows application that can have single or multiple forms which are the
means of GUI representation.
3. Then go to View ->ToolBox. Drag 2 TextBoxes from the ToolBox to the Design form
named Form1. In these 2 textboxes we will input 2 numbers for calculation. Give the
TextBoxes unique names: Select the TextBox ->Right Click -> Properties-> In Properties find
‘Name’ field and give a unique name to the Textbox. Suppose the 1st TextBox name is
txtNumber1 and the 2nd TextBox name is txtNumber2. See Expected Output Below.
4. Then we have to go to View ->ToolBox and add 4 Buttons for the operations (+,-,*, /).
Similarly give each Button a unique name in the ‘Name’ field. Here we have given the
Button’s name as follows: btnPlus, btnMinus, btnMultiplication and btnDivision. We also
have to show the symbols (+,-,*, /) on the Button. To do that, Select the 1st Button ->Right
Click ->Properties ->Find ‘Text’ field and write +. Do this for the other buttons as well. See
Expected Output Below.
5. Click the Buttons and perform the operations accordingly. So we have to write some
code for each Button’s ClickEvent. To do that, double click each button in the form and
then write the corresponding operations for the 2 numbers given input in the Textboxes
as shown below.
Code:
using System.Windows.Forms;
namespace SimpleForm
public Form1()
InitializeComponent();
{
double n1 = Convert.ToDouble(txtNumber1.Text);
double n2 = Convert.ToDouble(txtNumber2.Text);
double n1 = Convert.ToDouble(txtNumber1.Text);
double n2 = Convert.ToDouble(txtNumber2.Text);
double n1 = Convert.ToDouble(txtNumber1.Text);
double n2 = Convert.ToDouble(txtNumber2.Text);
double n1 = Convert.ToDouble(txtNumber1.Text);
double n2 = Convert.ToDouble(txtNumber2.Text);
}
Expected Output:
Reference:
https://toaz.info/doc-viewer