Write code in the 'OnCreate' event handler of the Form to change the text displayed on the pnlQ1_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 pnlQ1_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 pnlQ1_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
First, retrieve the current text from the pnlQ1_1 panel and assign it to a variable, say existingText:
string existingText = pnlQ1_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
Concatenate the dash and the system date to the existing text. You can use the DateTime.Now function to get the current date:
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
Convert the updatedText to upper case and set the modified text as bold:
string finalText = updatedText.ToUpper();
// Assume pnlQ1_1 has a property to set font style to bold
pnlQ1_1.Font.Bold = true;
pnlQ1_1.Text = finalText;