Chapter 1 : Introduction to Visual Programming Flashcards
What components respond to actions from users such as mouse clicks, pressing keys on keyboards or placing the mouse cursor over user interface objects
- Graphical User Interface ( GUI )
What are the actions known as ? ( mouse click, pressing key on keyboards )
- Event
What does a Visual C# applications project start with? ( 3 )
- Designer
- Toolbox
- Property Window
- An empty form is generated and its name is Form1
What is the form basic width and height
- 300 pixel each
What does the property window do?
- Change the settings for the appearance and other characteristics of a GUI object
What will be displayed in the column’s property list? ( 2 )
- Left Column
- Property’s Name
- Right Column
- Property’s Value
What is controls name
- Identifiers of the controls
List out the rules for naming controls
- The first character must be letter ( lower , uppercase doesn’t matter ) or an underscore
- All other characters can be alphanumerical characters or underscores
- The name cannot contain spaces
- Example
showDayButton
DisplayTotal
_ScoreLabel
List out 3 ways for how C# code is primarily organized?
- Namespace
- A container that holds classes
- Class
- A container that holds methods
- Method
- Group of one or more programming statements that perform some operations
What is a file that containes program code is called?
- Source Code File
What source code file that is automatically created when creating a new project?
- Program.cs
- Contains the application’s start-up code to be executed when the application runs
- Form1.cs
- Contains code that is associated with the Form1 form
- Can open through Solution Explorer
How does C# code is organized?
- As methods
What does a program waits in event-driven programming?
- An event to occur after executed
- Determine how controls ( button, textbox ) respond to events that are set for the respective control
Who controls the program response in event-driven programming?
- User
List out 3 ways that the event can occur
- The user doing something ( Click a button )
- Something happening within th ecomputer ( System Shutdown )
- Something happening within the program ( Program Crash )
List out 5 types of events
- Activate Events
- User selects item on screen
- Changed Events
- Control property modified
- Focus Events
- Control gets or loses focus
- Key Events
- User interacts with keyboard
- Mouse Events
- User interacts using mouse
What is an event handler? ( 2 )
- Method that executes when a specific takes place
- Code segment similar to the following will be created automatically
private void myButton_Click(object sender, EventArgs e)
{
}
What does a message box does?
- Displays a message
What is the code for showing a message box?
- MessageBox.Show(“Hello”)
- Placing it inside the event handler ( button ) can display the string in the message box when the button is clicked
What does a label do?
- Display text on a form and can be used to display unchanging text or program output
List out 6 commonly used properties
- Text ( Displayed text )
- Name ( Method name )
- Font
- BorderStyle
- AutoSize
- TextAlign
List out 9 values that the TextAlign property supports
- TopLeft
- TopCenter
- TopRight
- MiddleLeft
- MiddleCenter
- MiddleRight
- BottomLeft
- BottomCenter
- BottomRight
- Select by clicking the dropdown button in TextAlign property
How to change a property ( Change label text from “Hi” to “Hello” ) ?
- Use Assignment Operator ( = )
label1.Text = “Hello”;
- Details
1. Control name followed by a dot
2. Property to be modified ( left side , .Text )
3. Value to be assigned ( Right side , = “Hello” )
How to change the color properties?
- Using class name Color followed by a dot
label1.BackColor = Color.blue
How to use concatenation?
- With the + operator
label1.Text = “Welcome ” + “ to C#”;
What is the difference when the concatenation operator ( + ) is used in
1. int , double
2. string
- Arithmetic ( Add )
- Concatenate ( Join String )
How to change the form properties?
- Using this keyword
private void button1_Click(object sender, EventArgs e)
{
this.BackColor = Color.Red ;
}
- When the button1 is clicked, the background color will be changed to Red
What does IntelliSense does?
- Provides automatic code completion as I write programming statements
- Access through Ctrl + .
- Provides an array of options that make language reference easily accessible
List out C# comments for :
1. Single Line Comment
2. Multiline Comment
- //
- // This is single line
- /**/
- /*
This is
multiline comment
*/
- /*
Why does programmes frequently use blank lines and indentation in their codes?
- To make code more human-readable
What code should I add when I want to close an application’s form in code?
- this.Close()
- it is commonly used in an Exit button
private void exitButton_Click(object sender, EventArgs e)
{
// Close the form.
this.Close();
}
What causes syntax errors?
- Misspelled words and missing punctuation
How would IDE perform to when having Syntax Errors?
- Normally trapped by IDE as they are typed
- Explanation shown when cursor held over error
- Should be corrected before running program
What would compiler do when having syntax errors
- Uncorrected syntax errors
- Message box prompts user to continue
- Error list window displays compilation errors
MessageBox.Show(“Bye)
What underline style when a syntax error is found?
- Jagged line
Why Run-time errors occured?
- Invalid calculation
- Attempt to open a non-existent file
When does Run-time errors occured?
- Only apparent when program runs
What will be displayed when run-time errors occured?
- IDE displays a message box
- Nature of error
- Approximate location of error ( line number )