Creating and Using Controls
In this exercise, you will begin by opening an existing Windows Forms application. You will add a ToolBar control to the main form of the application, add the appropriate number of buttons to the ToolBar control, and set values for each of the buttons. After the design for the toolbar is complete, you will develop the code that handles the ButtonClick event of the toolbar and responds appropriately for each of the different buttons. You will then develop the code statements required to create...
Demonstration Expense Report Application
In this demonstration, you will see how to use the Expense Report application for non_trainer use In this demonstration, you will see how to use the Expense Report application. Note If you performed a default installation of the course files, install_folder corresponds to C Program Files Msdntrain 2565. 1. Open the InternalBusinessApp.sln solution file from the install_folder Sampapps Business Application Shell. 2. Mention that the business expense reporting application consists of two major...
SDI vs MDI Applications
You must close one document before you open another You must close one document before you open another Displays multiple documents at the same time Displays multiple documents at the same time Each document is displayed in its own window Before you create a Windows-based application, you must determine the style of user interface for the application. As the name suggests, single-document interface SDI applications can support only one document at a time, whereas a multiple-document interface...
How to Persist Application Settings
Complete control, but developer must write and maintain more code Good choice when application stores state in objects Choose a storage location Storing user data in a DataSet object Saving user data by using serialization There are many techniques that you can use to save user data in Windows Forms applications. Your application may use one or all of the following techniques, depending on its particular requirements. If you have just a few properties to save, the DataSet object is a good...
Handles Keyword
Declares that a procedure handles a specific event Allows you to specify event handlers at design time ProcedureDeclaration Events Argument list must match the usual list for the particular eventj Jles Under21.Cl Thirties.Cli Forties.Clic List of events that this routine will handle List of events that this routine will handle The way you construct an event handler depends on the way you want to associate it with events. The standard way to create event handlers is to use the Handles keyword...
How to Teach This Module Ciw
This section contains information that will help you to teach this module. If students are interested in referencing code examples in other languages, point them to Language Equivalents in the Microsoft Visual Studio .NET Help documentation. This section provides examples in languages such as Microsoft Visual Basic .NET, C , and Java. The lab at the end of this module is based on the Expense Report application in Course 2565A, Developing Microsoft .NET Applications for Windows Visual Basic .NET...
Practice Adding ADONET Objects to and Configuring ADONET Objects in a Windows
Add and configure a SQLConnection object on a Windows Form Add and configure a SQLDataAdapter control on a Windows Form Begin reviewing the objectives for this practice activity In this practice, you will add ADO.NET objects to and configure ADO.NET objects on a form by using Data Adapter Configuration Wizard. Create a Windows application project 2. On the File menu, point to New, and then click Project. 3. In the New Project dialog box, select Windows Application, name it BuildingDataSets,...
How to Create WindowsPrincipal and Windowsldentity Objects
Creating objects for a single validation Dim MyIdentity As WindowsIdentity _ WindowsIdentity.GetCurrent Dim MyPrincipal As WindowsPrincipal new WindowsPrincipal MyIdentity Creating objects for repeated validation AppDomain.CurrentDomai n.SetPrinci pal Policy _ PrincipalPolicy.WindowsPri nci pal Dim MyPrincipal As WindowsPrincipal _ System.Threadi ng.Thread.CurrentPrincipal As WindowsPrincipal There are two ways to create WindowsPrincipal objects, depending on whether code must repeatedly...
Practice Adding and Removing Controls at Run Time
Specify properties of the new control Begin reviewing the objectives for this practice activity In this practice, you will add and remove controls at run time. 1. Using Windows Explorer, navigate to installJolder Praciices Mod02 Mod02_03 Starter. 2. Double-click the AddingAndRemovingControls.sln solution file to open the project. 1. Open Form1.vb in the Code Editor. 2. On the View menu, point to Show Tasks, and then click Comment. 3. In the Task List, double-click TODO remove controls from...
Microsoft Hmi
Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is...
Deploying a NET Application
In this exercise, you will package the Expense Reporting application into a Windows Installer file by using a Setup and Deployment project. You will then install the application on the local computer. Note The Internal Business Application component of the Expense Reporting application requires that the Expense Report XML Web service be installed on the target computer. This exercise assumes that the Expense Report XML Web service has already been installed on the target computer. There are...
Lesson Protecting State and Data in a Multithreaded Environment
How to Protect State and Data in a Multithreaded Environment Demonstration Protecting State and Data in a Multithreaded Environment illegal for non-trainer use Introduction No synchronization is the default for objects. Therefore, when you use asynchronous programming techniques, you must consider how to protect state and data in this multithreaded environment. Lesson objective After completing this lesson, you will be able to describe techniques to protect state and data in a multithreaded...
Protecting State and Data in a Multithreaded Environment
illegal for non-trainer use 1. When and why would you use asynchronous programming techniques in an application You should use asynchronous programming techniques in an application with significant user interaction to avoid blocking the user interface during slow method calls, such as XML Web service calls. 2. In a Windows Forms application, what are the main steps to follow to use the asynchronous programming design pattern with an asynchronous callback for completion 1 Create the...
How to Create Hatch Filled Shapes
The HatchBrush object creates a hatched line fill pattern The HatchBrush constructor takes three arguments Color of the hatch lines A hatch brush allows you to select from a large variety of preset hatched line patterns to fill in a shape. Each hatch pattern is made from two colors one for the background and one for the lines that form the pattern over the background. To fill a closed shape with a hatch pattern, use a HatchBrush object. HatchBrush and HatchStyle are included in the...
How to Protect State and Data in a Multithreaded Environment
Interlocked.Increment and Interlocked.Decrement Design applications to try to minimize synchronization needs For many Windows Forms applications, little state protection code may be necessary, because most access of object state happens on the main thread. However, this will not be the case for every application. The System.Threading namespace provides classes and interfaces for synchronizing access to data to provide thread safety. You can use the SynchronizationAttribute on any class that is...
ADONET Objects
ADO.NET evolved from the ADO data access model. By using ADO.NET, you can develop applications that are robust and scalable and that can use XML. ADO.NET has some of the same objects as ADO like the Connection and Command objects , and introduces new objects, such as Dataset, DataReader, and DataAdapter. To move data between a data store and your application, you must first have a connection to the data store. In ADO.NET you can create and manage a connection by using a Connection object....
Demonstration Tracing the Assembly Loading Process
In this demonstration, you will see how to use the Fusion Log Viewer FUSLOGVW to trace the assembly loading process and solve probing errors In this demonstration, you will see how to use the Fusion Log Viewer FUSLOGVW to trace the assembly loading process and identify assembly loading problems probing errors . Important Prior to performing this demonstration, run the Fusion Log Viewer and enable the Log Failures checkbox. If you do not do so, the run time will not log probing errors and the...
How to Create GenericPrincipal and GenericIdentity Objects
Create and initialize a GenericIdentity object Dim MyIdentity As New GenericIdentity User1 Create and initialize a GenericPrincipal object and attach it to the current thread Dim MyStringArray 2 As String MyStringArray O Manager MyStringArray l Employee Dim MyPrincipal As New GenericPrincipa1 MyIdentity, _ Implementing role-based security by using GenericIdentity and GenericPrincipal objects You can use the GenericIdentity class in conjunction with the GenericPrincipal class to implement...
How to Teach This Module
Demonstration Expense Report Application This section contains information that will help you to teach this module. Welcome students to the course and introduce yourself. Provide a brief overview of your background to establish credibility. Ask students to introduce themselves and provide their background, product experience, and expectations of the course. Record student expectations on a whiteboard or flip chart that you can reference later in class. Tell students that everything they will...
Deploying Windows Forms Applications
In this module, you will learn about assemblies and the use of strong-named assemblies and the global assembly cache in the Microsoft .NET Framework. You will also learn how to configure and deploy your .NET applications. After completing this module, you will be able to Use strong-named assemblies in .NET applications. Use application configuration files to configure and use Microsoft Windows Installer 2.0 to package and deploy .NET applications.
Windows Forms DesignerGenerated Code
illegal for non-trainer use Introduction When you create a form by using Windows Forms Designer, the Designer generates a lot of code that you would have to write if you were creating a form on your own. Designer-generate code If you look at the default code for the form, you will find the following code Region Windows Form Designer generated code 'This call is required by the Windows Form Designer. Initia1izeComponent 'Add any initialization after the Initia1izeComponent call 'Form overrides...
How to Define Functions by Using the DllImport Attribute
DllImport attribute is used to define functions Parameters are used to specify specific behavior CallingConvention EntryPoint CharSet ExactSpelling Imports System.Runti me.InteropServices lt DllImport KERNEL32 .DLL, EntryPoint MoveFileW, SetLastError True, _ CharSet CharSet.Unicode, ExactSpelling True, _ _ MoveFile ByVal src As String, ByVal dst As String As Boolean The DllImport attribute provides an alternative way of using functions in unmanaged code. The DllImport attribute is used to...
Practice Creating and Using a Windows Installer Deployment Project
In this practice, you will create and test a Windows Installer deployment project for the WindowsCalculator application Begin reviewing the objectives for this practice activity In this practice, you will create a Microsoft Installer setup project and add the WindowsCalculator application to the project. You will then test the project to validate that the application installed and works correctly. 2. On the Start page, click New Project. 3. In the New Project window, in the Project Type pane,...
Dock controls on a form
In this demonstration, you will see how to organize controls on a form. Organize controls by using the Format menu 1. Open the WorkingWithControls project in Visual Studio .NET from installfolder Democode Mod01 Mod01_01 Starter. 2. If the WorkingWithControls.vb form is not visible, display it in Design view. You will notice that the controls on the forms are not organized very well. 3. Organize the buttons on the form so that the Display button is positioned to the left of the Exit button. 4....
Calling Win32 APIs from a NETBased Application
In this exercise, you create a class that exposes a Win32 API. You will then invoke the Win32 API by using your class from a Windows Forms application. The PlaySound function takes three arguments and returns a Boolean value that indicates whether or not the function was able to play the sound file. The arguments include A string that defines the name of the sound file. Hmod Handle to the executable file that contains the resource to be loaded. This parameter must be NULL unless SND_RESOURCE is...
How to Create a Path Gradient Filled Shape
Use a path gradient brush to customize the way you fill a shape with gradually changing colors Introduction The PathGradientBrush class enables you to create gradients with more than two colors and additional methods for customizing a gradient fill. For example, you can specify one color for the center of a path and another color for the outside edge. You can also specify separate colors for each of several points along the perimeter of a path. Procedure How to fill an The following example...
Using an Application Configuration File
In this exercise, you will create an application configuration file that will redirect the Internal Business Application to load a new version of the ExpenseReport.dll file. There are starter and solution files associated with this exercise. Browse to installfolder Labfiles Lab09_1 Ex04 Starter to find the starter files, and browse to install_folder Labfiles Lab09_1 Ex04 Solution to find the solution files. If you performed a default installation of the course files, installfolder corresponds...
Defining an Event and Raising It from an Extended Control
In this exercise, you will define an event for the NumericTextBox control, raise it from the control, pass event information, and respond to it from a host application. There are starter and solution files associated with this exercise. Browse to install_folder Labfiles Lab03_1 Ex01 Starter to find the starter files, and browse to install_ older Labfiles Lab03_1 Ex01 Solution to find the solution files. If you performed a default installation of the course files, install older corresponds to C...
Lesson Licensing a Control
How to Enable Licensing for a Control Demonstration Creating and Validating a License for a Control How LicFileLicenseProvider Works in .NET illegal for non-trainer use Introduction The .NET Framework provides a licensing model that is identical for all components including Windows Forms controls and ASP.NET server controls, although the implementation is different. Licensing allows control authors to protect their property by checking that a user is authorized to use the control. This check...
How to Teach This Module Qcx
This section contains information that will help you to teach this module. If students are interested in referencing code in other languages, point them to Language Equivalents in the Help documentation for the Microsoft Visual Studio .NET development system. This section provides examples in languages such Microsoft Visual Basic .NET, Microsoft Visual C gt and Java. Lab 4.1 Accessing Data by Using ADO.NET is based on the Purchase Order application in Course 2565A, Developing Microsoft .NET...
Inheriting a New Form from an Existing Windows Form
In this exercise, you will update the Internal Business Application shell by adding an About dialog by inheriting from a generic Windows Form. There are starter and solution files associated with this exercise. Browse to installfolder Labfiles Lab01_1 Ex02 Starter to find the starter files, and browse to install_folder Labfiles Lab01_1 Ex02 Solution to find the solution files. If you performed a default installation of the course files, installfolder corresponds to C Program Files Msdntrain...
Call the LayoutMdi method
Procedure Listing the child windows of a parent form In an MDI application, a parent form has several child forms, and each of the child forms interacts with the parent form. Visual Studio .NET includes several properties that allow parent and child forms in an MDI application to interact. An easy way to keep track of the different MDI child windows an application has open is to use a Window list. The functionality to keep track of all the open MDI child forms as well as which child form has...
Begin reviewing the objectives for 10 min this practice activity 1
In this practice, you will modify an existing form to allow it to be inherited by other forms. You will create a new form and inherit it from the base form. You will then modify the inherited form to customize it for a particular application. 1. Use Windows Explorer and browse to installfolder Practices Mod01 Mod01_02 Starter. 2. Double-click the WindowsCalculator.sln solution file to open the project. 1. If Solution Explorer is not visible, on the View menu, click Solution Explorer. 2. If the...
Begin reviewing the objectives for 15 this practice activity
In this practice, you will install the CalculatorEngine assembly in the global assembly cache. You will then build the WindowsCalculator application. Prior to running the application, you will remove all the local copies of CalculatorEngine.dll. You will then verify that WindowsCalculator still runs because it finds the correct version of CalculatorEngine in the global assembly cache. Important During development, you can use the Global Assembly Cache tool GACUtil to install your assembly in...




