This appendix contains information that will help you prepare for Exam 70-316, Developing and Implementing Windows-based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET. This is a Microsoft Certified Professional (MCP) exam, and it also provides credit for the certifications Microsoft Certified Solution Developer (MCSD), Microsoft Certified Application Developer (MCAD) for Microsoft .NET, and Microsoft Certified Database Administrator (MCDBA) on Microsoft SQL Server 2000.
When making modifications to a base form, you must build the form for inherited forms to reflect the changes.
You can use the IncrementalBuild functionality of project to decrease build times when you are working on new code and existing code does not need to be rebuilt.
When creating a multinational application, you should create a single executable file with the default culture embedded. Then create separate satellite assemblies for culture-specific resource files. You can use the Al.exe tool to compile the resource files into satellite assemblies.
The Invalidate method will cause a control to redraw itself, and thus any changes will be seen after calling this method.
You can use the IDisposable.Dispose method to control resource usage in resource-scarce environments.
If you want methods to be called when an object is created, call those methods in the constructor of a class.
An event may be invoked only by the class that defines it. The following is an example of calling a base class event from an inherited class:
if(base.Deceased != null)
Base.Deceased(this, e)
The Select event of a menu item is fired when the mouse points to a menu item or the arrow keys are used to navigate to the item.
When data binding is not being used, a forms Load event handler is used to place data into controls on the form.
The Closing event handler of a form can be used to prevent a form from closing if certain conditions have not been met. This requires the Cancel property of the CancelEventsArgs object to be set to true.
A TextBox TextChanged event handler can be used to examine the contents of a text box when it loses focus.
The QueryPageSettings event occurs before the BeginPrint event and provides you with the opportunity to set properties of the PageSettings object. The PageSettings object allows you to modify settings such as margins, paper source, and printer resolutions.
The following code can be placed in an event handler for a TextBox to set its value:
((TextBox)sender).Text = HUMAN_TOKEN
By setting the Cancel property of CancelEventArgs to true in a Validating event handler for a control, you suppress further events, and the control maintains the focus.
The Validating event of a control can be used to verify the contents of a control and prevent focus from moving to the next control when the Tab key is pressed. This also requires the Cancel property of the CancelEventArgs object to be set to true.
Setting the Dock property of a control to fill causes the control to fill the entire client area.
Setting the DialogResult property to yes allows for a dialog box to return results and close the form.
The ReshowDelay property determines the amount of time that must elapse before a previously viewed tooltip will allow the tooltip help to be reshown.
When you change the RightToLeft property of a form for countries where languages are read from right to left, the following things will occur:
Text in Label controls will be right-aligned.
The main menu will move to right side of the form and will appear in reverse order.
Text in buttons on a toolbar will not change.
The following is true when you set the DefaultItem property of a MenuItem to true:
The menu item's typeface will be bold.
Double-clicking a submenu containing the default item will select the default item.
The AccessibleName property of a control is spoken when it receives focus. You can restrict the size of a form by using the following code:
MyForm.MaximumSize = new Size(150,150);
The MaximumSize property prevents a form from exceeding the specified size.
The MaxLength property can be used to limit the number of characters typed into a text box.
Setting the TabStop property of each control on a form will prevent a user from tabbing through the controls on a form.
To use a shortcut key to transfer focus to a control, you must do the following:
In the label control's Text property use the & to set the shortcut (for example, &Phone ).
Set the value of the TabIndex of the label to be 1 plus the value of the label's TabIndex property.
Set the UseMnemonic property to true.
The shortcut key of a CheckBox is enabled by placing a % in the Text property. The & character should be placed before the letter you wish to be the shortcut. You must also set the AutoCheck property to true . This will allow a user to use the shortcut to check or uncheck a check box on demand.
The following code can be used to add an existing menu item to a new menu object such as a context menu:
PopupMenu.MenuItems.Add(MenuEditItem.Clone()) ;
To enable Help on any control that has focus by pressing F1, do the following:
Add a HelpProvider component to the form.
Set the HelpString property of the control to the text you want to appear when F1 is pressed.
Set the ShowHelp property of each control to true.
To bind a column in a DataSet to a Text property of TextBox, use this code:
TextBox.Add(new Binding("Text", MyDataSet, "YTD.TotalSales"));
To bind a ComboBox to columns in a DataSet, do the following:
Combo.ValueMember = "ProcCode"; Combo.DisplayMember = "ProcName";
The ValueMember property determines the value that is written. The DisplayMember property determines the column in the DataSet that is displayed.
When the LockControls option is enabled, the only way to set the size of a control in the Forms Designer is to use the width and size properties.