The document discusses writing code for a form in C#. It explains that code templates can be used to specify what should happen during events, like when a button is clicked. It provides instructions for double clicking a button to open the code editor, and describes how the event procedure name is formatted. It includes code to declare variables, convert text box values to doubles, check that the values are positive numbers, and close the form or display a message if the values are invalid.
The document discusses writing code for a form in C#. It explains that code templates can be used to specify what should happen during events, like when a button is clicked. It provides instructions for double clicking a button to open the code editor, and describes how the event procedure name is formatted. It includes code to declare variables, convert text box values to doubles, check that the values are positive numbers, and close the form or display a message if the values are invalid.
The document discusses writing code for a form in C#. It explains that code templates can be used to specify what should happen during events, like when a button is clicked. It provides instructions for double clicking a button to open the code editor, and describes how the event procedure name is formatted. It includes code to declare variables, convert text box values to doubles, check that the values are positive numbers, and close the form or display a message if the values are invalid.
C# can insert code templates for event procedures for controls. You modify the code template to specify what you want to happen when an event occurs, such as when users click the OK button. 1. Double-click the OK button on the form to open the Code Editor window containing an event procedure for this control. The name of the event procedure, bOK_Click, is a combination of the control's name as specified in the control's Name property, an underscore (_), and the name of the event. The Click procedure is the default procedure for a command button. 2. Type, or copy and paste, these declarations above Private void bOK_Click(object sender, EventArgs e). public double radius; public double depth; 3. Type, or copy and paste, this code between Private void bOK_Click(object sender, EventArgs e) event's curly brackets. double radiusResult; double depthResult; //Convert strings to doubles and //make sure that the text in the two //text boxes on the form are positive, //non-zero, numeric values double.TryParse(txtRadius.Text, out radiusResult); double.TryParse(txtDepth.Text, out depthResult); if (radiusResult > 0 && depthResult > 0) { radius = radiusResult; depth = depthResult; //Close the form and continue Close(); } else { //Display a message box telling the user to type //positive, non-zero, numeric values in both text boxes MessageBox.Show("You must type positive, non-zero, numeric values in both Radius and an Depth."); }
JavaScript Fundamentals: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers
JavaScript Fundamentals: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers