Write code in the "OnCreate" event handler of the Form to change the text displayed on the pnl01_1 panel as follows when the program is executed:
- Assign the existing text from the panel to a variable - NSC Information Technology - Question 1 - 2018 - Paper 1
Question 1
Write code in the "OnCreate" event handler of the Form to change the text displayed on the pnl01_1 panel as follows when the program is executed:
- Assign the exist... show full transcript
Worked Solution & Example Answer:Write code in the "OnCreate" event handler of the Form to change the text displayed on the pnl01_1 panel as follows when the program is executed:
- Assign the existing text from the panel to a variable - NSC Information Technology - Question 1 - 2018 - Paper 1
Step 1
Assign the existing text from the panel to a variable.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Retrieve the current text displayed on the pnl01_1 panel and assign it to a variable, for example, string existingText = pnl01_1.Text;.
Step 2
Add a dash "-" and use the relevant function to also add the system date to the text.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Use the DateTime.Now function to get the current date and concatenate it with the existing text and a dash. For example: string newText = existingText + " - " + DateTime.Now.ToString("yyyy/MM/dd");.
Step 3
Change the text to upper case and display the text in bold.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Modify the new text to be in upper case by using newText.ToUpper(), and set the Font.Bold property for the panel before assigning the modified text back to it: pnl01_1.Font.Bold = true; pnl01_1.Text = newText.ToUpper();.