- •maranGraphics
- •CREDITS
- •ACKNOWLEDGMENTS
- •ABOUT THE AUTHORS
- •AUTHORS’ ACKNOWLEDGMENTS
- •TABLE OF CONTENTS
- •HOW TO USE THIS BOOK
- •INTRODUCTION TO C#
- •START VISUAL STUDIO .NET
- •OPEN A NEW C# PROJECT
- •OPEN A C# WEB PROJECT
- •SET JSCRIPT .NET AS THE DEFAULT SCRIPT LANGUAGE
- •EXPLORE THE CLASS VIEW WINDOW
- •VIEW THE CONTENTS WINDOW
- •GET HELP USING THE INDEX WINDOW
- •SEARCH FOR HELP
- •ADD COMPONENTS FROM THE TOOLBOX
- •ADD A TASK TO THE TASK LIST
- •CHANGE FORM PROPERTIES IN THE PROPERTIES WINDOW
- •ADD A CUSTOM TOOLBAR
- •DELETE A TOOLBAR
- •CHANGE THE VISUAL STUDIO ENVIRONMENT
- •MANAGE OPEN WINDOWS
- •OPEN A PROJECT
- •VIEW THE MAIN METHOD
- •COMBINE PROGRAM TYPES
- •ADD REFERENCE TYPES
- •ADD OPERATORS
- •INSERT ATTRIBUTES
- •ENTER CLASSES
- •ADD COMMENTS TO CODE
- •WRITE YOUR FIRST PROGRAM
- •ENTER XML DOCUMENTATION
- •ACCESS DOCUMENTATION
- •LOG A BUG REPORT
- •VIEW INFORMATION ABOUT C# BUILDING BLOCKS
- •PROGRAM CLASSES
- •ADD A CLASS
- •EMPLOY CLASS INHERITANCE
- •PROGRAM INSTANCE CONSTRUCTORS
- •INSERT DESTRUCTORS
- •PROGRAM STRUCTS
- •DISPLAY HEAP AND STACK INFORMATION
- •FIND TYPE INFORMATION
- •PROGRAM CONSTANT EXPRESSIONS
- •SPECIFY VALUE TYPES
- •PROGRAM NUMERIC TYPES
- •PROGRAM THE BOOLEAN TYPE
- •DECLARE REFERENCE TYPES
- •ENTER REFERENCE TYPE DECLARATIONS
- •CONVERT VALUE TYPES TO REFERENCE TYPES
- •PROGRAM POINTER TYPES
- •INSERT THE VOID TYPE
- •ADD INTERFACE PROPERTIES
- •ADD AN INTERFACE INDEX
- •VIEW INFORMATION ABOUT METHODS
- •ADD A METHOD
- •ADD STATIC METHODS
- •INCLUDE NON-STATIC METHODS
- •ENTER DELEGATES
- •PROGRAM EVENTS
- •ADD AN EVENT-HANDLING METHOD
- •VIEW INFORMATION ABOUT ARRAYS
- •ENTER SINGLE-DIMENSIONAL ARRAYS
- •ADD MULTIDIMENSIONAL ARRAYS
- •PROGRAM ARRAY-OF-ARRAYS
- •ITERATE THROUGH ARRAY ELEMENTS
- •SORT ARRAYS
- •SEARCH ARRAYS
- •IMPLEMENT A COLLECTIONS CLASS
- •PROGRAM STRUCTS
- •ADD AN INDEXER
- •INCLUDE ENUMERATIONS
- •CREATE STRING LITERALS AND VARIABLES
- •ASSIGN VALUES TO STRINGS
- •CONCATENATE STRINGS
- •COMPARE STRINGS
- •SEARCH FOR SUBSTRINGS
- •REPLACE CHARACTERS
- •EXTRACT SUBSTRINGS
- •CHANGE THE CHARACTER CASE
- •TRIM SPACES
- •REMOVE CHARACTERS
- •SPLIT A STRING
- •JOIN STRINGS
- •PAD STRINGS
- •VIEW INFORMATION ABOUT PROPERTIES
- •COMPARE PROPERTIES AND INDEXERS
- •PROGRAM PROPERTY ACCESSORS
- •DECLARE ABSTRACT PROPERTIES
- •INCLUDE PROPERTIES ON INTERFACES
- •VIEW INFORMATION ABOUT WINDOWS FORMS
- •ADD A WINDOWS FORM IN THE WINDOWS FORM DESIGNER
- •SET THE FORM TYPE
- •CHOOSE THE STARTUP WINDOWS FORM
- •CREATE A MODAL FORM
- •LAYOUT A FORM
- •SET A FORM LOCATION
- •CHANGE FORM PROPERTIES
- •CREATE A TRANSPARENT FORM
- •AN INTRODUCTION TO WEB FORMS AND CONTROLS
- •CREATE AN ASP.NET WEB SITE
- •CREATE A WEB FORM
- •ADD SERVER CONTROLS TO A WEB FORM
- •READ AND CHANGE PROPERTIES FROM OBJECTS ON A WEB FORM
- •USING SERVER-SIDE COMPONENTS ON WEB FORMS
- •INTRODUCING DATA ACCESS WITH ADO.NET
- •DISPLAY DATA WITH THE DATAGRID CONTROL
- •CONFIGURE THE DATAGRID CONTROL
- •INSERT DATA INTO A SQL DATABASE
- •UPDATE DATA FROM A SQL DATABASE
- •DELETE DATA FROM A SQL DATABASE
- •EXECUTE A STORED PROCEDURE IN A SQL DATABASE
- •READ XML FROM A FILE
- •SAVE XML TO A FILE
- •QUERY XML WITH XPATH
- •APPLY XSL TO XML
- •INTRODUCTION TO DISTRIBUTED APPLICATIONS
- •CREATE AN APPLICATION WITH PRIVATE ASSEMBLIES
- •CREATE AN APPLICATION WITH SHARED ASSEMBLIES
- •VERSION A SHARED ASSEMBLY
- •CONFIGURE A CLIENT FOR A VERSIONED ASSEMBLY
- •CREATE A WEB SERVICE
- •USING A WEB SERVICE
- •INTRODUCTION TO EXCEPTION HANDLING
- •THROWING AN EXCEPTION
- •HANDLING EXCEPTIONS WITH THE CATCH BLOCK
- •USING THE FINALLY BLOCK
- •WRITE ERRORS TO THE APPLICATION LOG
- •BASIC EXAMPLES
- •WHAT’S ON THE CD-ROM
- •USING THE E-VERSION OF THIS BOOK
- •INDEX
- •Symbols & Numbers
C#
CHANGE FORM PROPERTIES IN THE PROPERTIES WINDOW
The Properties window appears in the lower-right corner of the parent window. The Properties window contains the information that pertains to a specific
object. For example, if you create a Windows application, the form appears in the parent window; a form lets a user input information so your C# program can manipulate it.
The form properties, including the form name, appear in the Properties window. When you change the form name, that name will appear on the form when you run your program.
The Properties window reflects information in the currently selected object. The Properties window contains a list of all objects in the program that you can alter in the properties window.
Many objects contain names or values that you can edit directly in the Properties window. Some object attributes have check boxes that you can click to enable or disable the object attribute. The Properties window also provides a description about a selected object attribute in case you are not familiar with what an attribute does.
Some object attributes in the Properties window contain more information than what the attribute value provides, such as font size, that you can edit in the Properties window. You can also sort the attributes in the Properties window if you want to see certain types of properties, such as events.
CHANGE FORM PROPERTIES IN THE PROPERTIES WINDOW
Form1.cs
Properties
Text Form1
|
|
|
|
|
|
If the Text field does not |
|
‹ Double-click the Form1 |
|
|
|
|||
appear, scroll through the |
name. |
|||
Properties window until you |
|
|
|
|
|
the Text attribute |
|
|
|
|
the Attributes heading. |
|
|
|
EXPLORING THE C# INTERFACE 2
Form1.cs
Properties
Text
› Type in the new name for |
ˇ Press Enter. |
■ |
your form. |
|
|
C#
ADD A CUSTOM TOOLBAR
Toolbars appear near the top of the MDE window, enabling you to access commands that you use most often without having to remember where a specific
command is in a menu; instead, you can just click a button. The MDE window has 25 built-in toolbars; the Standard toolbar appears by default and others appear when you perform a particular function. For example, the Layout toolbar appears when you edit a form. You can also add your own custom toolbars to access the features you use.
Custom toolbars can reduce the number of active toolbars in the parent window. If you prefer accessing commands using the keyboard, Visual Studio .NET also lets you set keyboard combinations for different commands.
Visual Studio .NET also lets you determine how information on the toolbar appears on your screen. For example, you can determine if you want the toolbar icons to also contain their text descriptions. Doing so makes it much easier to determine what a command does, especially if you are not familiar with all of the toolbar buttons, but they do add additional space to your toolbar that will take away from other space in your window. An alternative method that saves space is to have ScreenTips on toolbars active so a button description appears when you move the mouse pointer over a toolbar button.
ADD A CUSTOM TOOLBAR
Customize
¤ Click to select Customize from the pop-up menu that appears.
Build
Form1.cs
Custom 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
■ The Customize dialog |
|
|
› Click New. |
|||||||
|
|
|||||||||
box appears. |
|
ˇ Type the new toolbar |
||||||||
|
‹ Click the Toolbars tab. |
|
||||||||
|
|
name. |
||||||||
|
||||||||||
|
|
|
|
|
|
|
|
Á Click OK. |
||
|
|
|
|
|
|
|
|
EXPLORING THE C# INTERFACE 2
You can reset the number of toolbars to the Visual Studio .NET default — the Standard and Web toolbars — by clicking the Reset button in the Customize window’s Toolbars tab.
Visual Studio .NET has default settings for what drop-down menu options appear when you click an option on the menu. The most recent options that you used appear first, and then the rest of the options appear after the drop-down menu has been open for a short time. You can reset this information by clicking the Reset my usage data button in the Customize window’s Options tab.
If you want to know what the keyboard shortcuts are for certain tabs without having to look them up in the Customize window, you can click the Show shortcut keys in ScreenTips check box in the Customize window’s Options tab. After you check the check box, you can move the mouse pointer over a Toolbar button and the description and keyboard shortcut (if there is one) will appear in the ScreenTip next to the pointer.
File
■ The custom toolbar appears in the middle of the parent window. You can click and drag to another area.
‡ Right-click the custom toolbar.
° Click to select Customize from the pop-up menu that appears.
Form1.cs
|
· Click the Commands tab |
|
|
|
|
|
|
|
|
||
|
|
■ The command appears in |
|||
|
|
||||
in the Customize window. |
|
the custom toolbar. |
|||
|
‚ Click to select a |
|
|
|
|
|
|
|
|
||
command category. |
|
|
|
||
|
— Drag the command you |
|
|
|
|
|
|
|
|
||
want to add to the custom |
|
|
|
||
toolbar. |
|
|
|
||
|
|
± Click the Close button in |
|
|
|
|
|
|
|
|
|
the Customize window. |
|
|
|
Solution Explorer - . . .
Form1.cs
■ You can access the command button in the custom toolbar by clicking.
29