C# coding
The first thing you are supposed to do when coding is assigning variables. Eg. String, int
Eg. String studentNumber; (local variables name)
String studentName;
Next you are going to say were the data is going to be collected from or too
studentNumber = txtStudentNumber.Text; (name of textbox)
studentName = txtStudentName.Text;
For int:
Int num1;
Num1 = int.parse(txtNum1.text);
Message Boxes
Several ways to code a message box. Message Box pdf for more methods.
MessageBox.Show(“Message that you want displayed”, “Title of message box”,MessageBoxButton.Ok (or
whatever button you want), MessageBox.Icon.Information (again can vary));
Line Breaks
Environment.Newline or \r\n or \n
Tooltips
Add message in properties by Tooltip on tooltip1 in textbox properties.
How to close a program
Close();
Access keys
Place a ‘&’ before the letter you want to be an access key
Changing the colour of the control
To change the colour of something due to another action click on that button and enter the name of the thing
you want to change followed by .BackColor = Color.(choose colour);
To change font click on font in properties.
Adding the enter and esc buttons
Set accept button in properties to true (enter button)
Set cancel button to true in properties (esc button)
, Data Types
For values use “=”. More in operators pdf.
Constants
Const type indentifier = expression;
OR public const int
To convert to a currency
(Variable name).ToString(“C”)
To show answer in textbox
(nameoftextbox).text = (variablename).ToString;
To disable a textbox
(textboxname).enabled = false;
Summaries
Variable += 1 or variable that is being counted.
Remember to set variable to 0 at beginning OR declare variable with constants and only set to 0 in method it is
being used. Do not forget ToString() in message box.
The first thing you are supposed to do when coding is assigning variables. Eg. String, int
Eg. String studentNumber; (local variables name)
String studentName;
Next you are going to say were the data is going to be collected from or too
studentNumber = txtStudentNumber.Text; (name of textbox)
studentName = txtStudentName.Text;
For int:
Int num1;
Num1 = int.parse(txtNum1.text);
Message Boxes
Several ways to code a message box. Message Box pdf for more methods.
MessageBox.Show(“Message that you want displayed”, “Title of message box”,MessageBoxButton.Ok (or
whatever button you want), MessageBox.Icon.Information (again can vary));
Line Breaks
Environment.Newline or \r\n or \n
Tooltips
Add message in properties by Tooltip on tooltip1 in textbox properties.
How to close a program
Close();
Access keys
Place a ‘&’ before the letter you want to be an access key
Changing the colour of the control
To change the colour of something due to another action click on that button and enter the name of the thing
you want to change followed by .BackColor = Color.(choose colour);
To change font click on font in properties.
Adding the enter and esc buttons
Set accept button in properties to true (enter button)
Set cancel button to true in properties (esc button)
, Data Types
For values use “=”. More in operators pdf.
Constants
Const type indentifier = expression;
OR public const int
To convert to a currency
(Variable name).ToString(“C”)
To show answer in textbox
(nameoftextbox).text = (variablename).ToString;
To disable a textbox
(textboxname).enabled = false;
Summaries
Variable += 1 or variable that is being counted.
Remember to set variable to 0 at beginning OR declare variable with constants and only set to 0 in method it is
being used. Do not forget ToString() in message box.