Top Posters
Since Sunday
p
6
I
6
h
5
k
5
a
5
J
5
k
5
r
5
O
5
x
5
d
4
s
4
A free membership is required to access uploaded content. Login or Register.

Framework 2.0 Based Client Development.docx

Uploaded: 6 years ago
Contributor: redsmile
Category: Operating Systems
Type: Other
Rating: N/A
Helpful
Unhelpful
Filename:   Framework 2.0 Based Client Development.docx (222.16 kB)
Page Count: 85
Credit Cost: 1
Views: 140
Last Download: N/A
Transcript
Microsoft .NET Framework 2.0 - Windows -Based Client Development QUESTION 1: You are creating a Windows Form that contains several ToolStrip controls. You need to add functionality that allows a user to drag any ToolStrip control from one edge of the form to another. What should you do? Configure a ToolStripContainer control to fill the form. Add the ToolStrip controls to the ToolStripContainer control. Configure a Panel control to fill the form. Set the Anchor properties of the ToolStrip controls to Top, Bottom, Left, Right. Add a ToolStrip controls to another ToolStrip control that is hosted by a ToolStripControlHost control. Add the ToolStrip controls to the form. Set the Anchor properties of the ToolStrip controls to Top, Bottom, Left, Right. Set the FormBorderStyle property of the form to SizableToolWindow. Answer: A QUESTION 2: You need to create a Windows Forms application that uses a nonrectangular form as its user interface. What should you do? A. Set the FormBorderStyle property of the form to None. Set the BackgroundImage property of the form to a bitmap file that represents the shape you want form to take. Set the TransparencyKey property to the background color of the bitmap file. B. Set the FormBorderStyle property of the form to None. Set the BackgroundImage property of the form to a bitmap file that represents the shape you want the form to take. Set the TransparencyKey property to Transparent. C. Set the FormBorderStyle and BackgroundImageLayout properties to None. Set the BackgroundImage property of the form to a bitmap file that represents the shape you want the form to take. Set the TransparencyKey property to Transparent. D. Set the FormBorderStyle property to None and the BackColor property to Control. Set the BackgroundImage property of the form to a bitmap file that represents the shape you want the form to take. Set the TransparencyKey property to Transparent. Answer: A QUESTION 3: You create a Windows Forms application. Your application executes a background thread. You need to construct the thread to exit, but you also need to notify the main thread when the background thread has ended. What should you do? Call the Abort method of the thread. Call the Interrupt method of the thread. Call the Join method of the thread. Call the Sleep method of the thread. Answer: C QUESTION 4: You are creating a Windows Forms application that uses a drag-and-drop operation to enable users to copy customer data between a ListBox control and RichTextBox control. The ListBox displays a list of customer Ids to the user. Each item in the ListBox is associated with a custom external data type named CustomerData. The data type stores the customer name along with other customer information, including the address and postal code. You need to ensure that when the user drags a customer name from the ListBox to the RichTextBox all of the information in your custom data type is moved into the RichTextBox. What should you do? A. Initiate the drag-and-drop operation in the MouseDown event for the ListBox. Call the DoDragDrop method for the ListBox, passing in an instance of CustomerData. Use the GetFormats method in the DragEnter event for the RichTextBox to access the custom data type. B. Initiate the drag-and-drop operation in the MouseDown event for the ListBox. Call the DoDragDrop method for the ListBox, passing in an instance of CustomerData. Use the GetData method in the DragDrop event for the RichTextBox to access the custom data type. C. Initiate the drag-and-drop operation in the MouseDown event for the ListBox. In the DragEnter or DragDrop events for the RichTextBox, set the Effect property to DragDropEffects.All. Use the GetFormats method in the DragEnter event for the RichTextBox to access the custom data type. D. Initiate the drag-and-drop operation in the MouseDown event for the ListBox. In the DragEnter or DragDrop events for the RichTextBox, set the Effect property to DragDropEffects.All. Use the GetDataPresent method in the DragEnter event for the RichTextBox to access the custom data type. Answer: B QUESTION 5: You are creating multiple-document interface (MDI) Windows Forms application. You need to configure the main form to function as the parent form and a second form to function as the child form. What should you do? Set the IsMdiContainer property of the parent form to True. Set the MdiParent property of the child form to the parent form. Set the IsMdiContainer property of the parent form to True. Set the Parent property of the child form to the parent form. Add the child form to the Controls collection of the parent form. Set the MdiParent property of the child form to the parent form. Add the child form to the Controls collection of the parent form. Set the Parent property of the child form to the parent form. Answer: A QUESTION 6: You are adding accssibility functionality to a custom, owner-drawn control named Legend. You create a class named AccessibleLegend, which is derived from the AccessibleObject class. The Legend control overrides the GetChild method and returns an AccessibleLegend object. You need to ensure that when the Legend control is disabled, the control still returns the appropriate value for the State property of the AccessibleLegend object. Which value should you configure the State property to return? AccessibleStates.Invisible AccessibleStates.Protected AccessibleStates.ReadOnly AccessibleStates.Unavailable Answer: D QUESTION 7: You are creating a Windows Forms application. Your application uses a custom control. The Custom control is based on a standard button control. You add several extra properties to the control. Some of these properties are read-only. You need to ensure that the read-only properties are not displayed in the Properties window of the design environment. What should you do? Decorate the read-only properties by using the EditorBrowsable attribute, and then set the EditorBrowsable attribute to EditorBrowsableState.Never. Use the DesignTimeVisible attribute, and then set the DesignTimeVisible attribute to False. Decorate the read-only properties by using the Borwsable attribute, and then set the Browsable attribute to False. Decorate the read-only properties by using the DisplayName attribute, and then set the DisplayName attribute to null. Answer: C QUESTION 8: You create a custom control by extending a standard TextBox control. The custom control adds a new property called ValidationColor. You need to ensure that uses can select the color for the ValidationColor property from the Properties window at design time by using the color action palette that is available for other standard Windows Forms controls. What should you do? Create a custom context menu that contains the chosen color palette and logic. Implement the IcontainerControl interface for your control. Create a custom dialog box that contains the chosen color palette and logic. Configure the FormBorder property of the dialog box to None. Implement the IcontainerControl interface for your control, and use its ActivateControl method to activate the dialog box. Create a custom dialog box that contains the chosen color palette and logic. Configure the FormBorder property of the dialog box to None. In the Set method of your property, write code to instantiate the dialog box and return the selected value. Declare the type of the property as System.Drawing.Color. Answer: D QUESTION 9: You created a custom Windows Forms control that contains width, Height, and SquareFootage properties. The SquareFootage property contains the multiplied value of Width and Height. You need to make SquareFootage visible, while disabling it in the property grid. What should you do? Apply the NotSerialized() attribute to the SquareFootage property. Apply the DesignerSerializationVisibility() attribute to the SquareFootage property, and pass in a value of DesignerSerializationVisibility.Content as a parameter. Appliy the EditorBrowsable attribute to the SquareFootage property, passing in a value of EditorBrowsableState.Never as a parameter. Implement the property by using only a Get accessor. Answer: D QUESTION 10: You are customizing a Windows Form. You want to display a custom icon for your composite control named DialerControl in the toolbox. You need to customize the toolbox icon. You want to achieve this goal by using the minimum amound of effort. Which action or actions should you perform? (Choose all that apply.) Add a bitmap named DialerControl.bmp to the user control project. Change the build action of the bitmap to Embedded Resource. Add a ToolboxBitmap attribute to the DialerControl class, passing in DialerControl.bmp as a parameter. Add a ToolboxBitmap attribute to the DialerControl class, passing in typeof(DialerControl) as a parameter. Answer: A. B QUESTION 11: You create a new custom control by extending a standard TextBox control. You need to replace the default icon for the control with your own custom icon. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.) Add the bitmap file that contains the custom icon to the custom control project. Set it's BuildAction property to Compile in the properties window. Add the bitmap file that contains the custom icon to the custom control project. Decorate the control class with the ToolboxBitmap attribute, and specify the location of the bitmap file for the icon. Add the bitmap file that contains the custom icon to the custom control project. Give the bitmap file the same name as your control class, and use the .bmp or .ico file name extention. Set it's BuildAction property to EmbeddedResource in the Properties window. Add the bitmap file that contains the custom icon to the custom control project. Give the bitmap file the same name as your control class, and use the .bmp or .ico file name extention. Set the Copy to Output Directory property of the bitmap to Copy always. Answer: B, C QUESTION 12: You are creating a Windows Form that includes print functionality. The form includes a PrintDocument control. A PrintPage event handler contains code that renders the form data to a default printer. You need to display a preview of the printed document along the lower edge of the form. Set the PrinterSettings.PrinterName property of the PrintDocument control to Preview. Add a second PrintDocument control to your form. Set the PrintController property of the PrintDocument type to a new instance of the PreviewPrintController type. C. Add a PrintPreviewControl control to your form. Set the PrinterSettings.PrinterName property of the PrintDocument control to the Name property of the PrintPreviewControl control. D. Add a PrintPreviewControl control to your form. Set the Document property of the PrintPreviewControl control to the existing PrintDocument instance. Answer: D QUESTION 13: You are creating a Windows Forms application that manages document creation. You need to display a customized print preview of the document that show within the main form. You want the customized view to display without the standard print preview user control. What should you do? A. Use the PrintPreviewDialog component. Set the Document property to the document to be printed. Use the ShowDialog method to display the control. B. Use the PrintPreview control. Set the Document property to the document to be printed. C. Use the PrintPreviewDialog component. Set the Document property of the control to the document to be printed. Use the Show method to display the control. Use the MainMenuStrip property to configure the user controls you want. D. Use the PrintPreview control. Set the Name property to the name of the document to be printed. Answer: B QUESTION 14: You are creating a Windows Forms application. Users need to preview print jobs before printing from the application. You added a PrintDocument component and PrintPreviewDialog component to the form. You need to configure the application to allow users to preview print jobs. You want to achieve this goal by using the minimum amount of effort. Which three action should you perform? (Each correct answer presents part of the solution. Choose three.) Set the PrintPreviewDialog.Document property to the PrintDocument component instance. Add a PringDialog component to the form. Set the PrintDialog.Document property to the PrintDocument component instance. Create an event handler for the PrintDocument.PrintPage event. Call the PrintDialog.ShowDialog method. Call the PrintPreviewDialog.ShowDialog method. Answer: A, D, F QUESTION 15: You are modifying an existing installation package for your application. Your application requires Microsoft Windows Server 2003 and will not run on Microsoft Windows 2000 Server. You add the following condition to the primary output of your installer. VersionNT >= 502 Users who previously attempted to install your application on Windows 2000 Server report that they still cannot install your application after than upgrade to Windows Server 2003. You need to ensure that users who upgrade the operating system on their servers to meet your launch condition can successfully ..install your application. What should you do? Set the Transitive property of the primary output to True. Change the UpgradeCode property of your Setup application. Set the Vital property of the primary output to True. Change the launch condition of your primary output to VersionNT >= 500. Answer: A QUESTION 16: You created a custom action for your Windows setup application. The custom action runs a standard Console application at the end of the installation process. You place the custom action in the Install node of the Custom Actions tree in the Custom Actions Editor. The Console application executable performs correctly when run as a stand-alone application. However, when you run the Microsoft Windows Installer package that was created by your setup application, the custom action does not run. Everything else works fine. You need to ensure that the console application runs during the install. What should you do? Set the InstallerClass property of your custom action to False. Place the custom action in the Commit node of the Custom Action tree rather than in the Install node. Set the DetectNewerInstalledVersion property for your setup application True. Set the InstallAllUsers property for your setup application to True. Answer: A QUESTION 17: You are configuring a ClickOnce deployment that allows users to install your application from the Internet zone under partial trust permission. You want the application to access data that resides on the same remote server from the application is installed. You need to add one of more types of data access that are allowed under partial trust permissions to your application. Which type or types of data access are allowed? (Choose all that apply.) data access through HTTP with System.Net.WebClient data access through XML Web services data access through System.Data.SqlClient data access through HTTP with System.Net.HttpWebRequest Answer: A, B, D QUESTION 18: You want to create a custom installer component to install your Windows-based application on client computers. Which three actions should you perfrom? (Each correct answer presents part of the solution. Choose three.) Inherit from the Installer class. Inherit from the AssemblyInstaller class. Add the RunInstallerAttirubte to your derived class and set it to True. Add the InstallerTypeAttribute to your derived class and set it to CustomInstaller. Register the installer. Override the install, Commit, Rollback, and Uninstall methods as required. Answer: A,C,F QUESTION 19: You are creating an installation package for a .Net Framework application. You need to configure your insatllation package to add a shourtcut to the user's destkop during installation. Which editor in the setup project should you use? File Types Editor User Interface Editor Custom Action Editor File System Editor Answer: D QUESTION 20: You are creating a Windows Forms application. You want the installer to display an HTML document that contains important information after users install your application. You need to configure your application to display the HTML document. What should you do? Set the SupportUrl property of your primary output to the path of the HTML document. Create a Custom Install Action hat calls the Process.Start method, passing in the path of the HTML document as the fileName parameter. Set the PostBuild event of your installation project to the path of the HTML document. Create a Custom Commit Action that calls the Process.Start method, passing in the path of the HTML document as the fileName parameter. Answer: D QUESTION 21: You are creating a ClickOnce application that requires elevated permissions by default. You need to identify the default security zones for each deployment location. Which default security zone is appropriate to use in each deployment location? All answer, drag the appropriate security zones to the correct deployment locations in the answer area. Each security zone can be used more than one. Answer: QUESTION 22: You are creating a Windows Forms application. The application displays data from a Microsoft SQL Server 2005 database in a DataGridView control. The DataGridView control is populated by a data table. The data table is filled by using a SqlDataAdapter object. You need to display changes to the database as they happen without polling the database. What should you do? A. Create a SqlDependency object and bind it to a SqlCommand object that is used by the SqlDataAdapter object. Reload the dataset in an event handler that is registered for the OnChanged event of the SqlDendency object. Use a TransactionScope block when calling the Fill method of the SqlDataAdapter object. Set the CommandTimeout property of the SqlCommand object that is used by the SqlDataAdapter object to -1. Reload the data table in an event handler that is registered for the RowChanging event of the DataTable object. Answer: A QUESTION 23: A method in your Windows Forms application executes a stored procedure in a Microsoft SQL Server 2005 database, and then executes a second stored procedure in a second SQL Server 2005 database. You need to ensure that the call to the first stored procedure writes changes only if the call to the second stored procedure succeeds. Destination requirements prohibit you from introducing new components that use the COM+ hosting model. What should you do? A. Implement a transactional serviced component. Add methods to this component to encapsulate the connet operation and execution of each stored procedure. Reqister and use this serviced component. B. Add a TransactionScope block. Connect to each database and execute each stored procedure within the TransactionScope block. Call the TransactionScope.Complete method if the call to both stored procedure succeeds. C. Connect to both databases. Call the SqlConnection.BeginTransaction method for each connection. Call the SqlTransaction.Commit method on both returned transactions only if both stored procedures succeed. D. Add a try-catch-finally block. Connect to each database and execute each stored procedure int the try block. Answer: B QUESTION 24: A Windows Forms application programmatically creates the schema for a dataset. The dataset includes a data table named Departments. The Departments table includes columns named DepartmentID and DepartmentName. You need to ensure that the Departments table assigns a unique integer value to the DepartmentID column when a new row is added. What should you do? Set the expression property of the DepartmentID column to "DepartmentID + 1". Add a Unique constraint for the DepartmentID column. Set the AutoIncrement property of the DepartmentID column to True. Designate the DepartmentID column as the primary key. Answer: C QUESTION 25: You are creating multiple threads in you application that will execute the same method. You need to synchronize access to a block of code within the method so that no two threads execute the block at the same time. What should you do? Add a SynchronizationAttribute attribute to the method that the multiple threads will call. Call the Monitor.Enter method before the block of code you want to synchronize, and then call the Monitor.Exit method after the block of code you want to synchronize. Use the Thread.BeginCriticalRegion method before the block of code you want to synchronize and the Thread.EndCriticalRegion method after the block of code you want to synchronize. Call the Interlocket.Increment method before the block of code you want to synchronize, and then call the Interlocked.Decrement method after the block of code you want to synchronize. Answer: B QUESTION 26: You are creating a Windows Forms application. You create a class named ApplicationUtilities and add a method named BackgroundProcess. You anticipate that the BackgroundProcess method may require several minutes or longer to execute. You need to ensure that the application remains responsive while the BackgroundProcess method runs. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.) Create an instance of a System.Threading.ThreadStart delegate named AsyncDelegate, and pass the BackgroundProcess method in as a parameter. Create a delegate named AsyncDelegate that matches the signature of the BackgroundProcess method. Implement the IasyncResult interface for the ApplicationUtilities class. Override the BeginInvoke and EndInvoke methods for the ApplicationUtilities class. Call AsyncDelegate.BeginInvoke to execute to method. After the method is complete, call AsyncDelegate.EndInvoke. Call ApplicationUtilities.BeginInvoke to execute the method. After the method is complete, call ApplicationUtilities.EndInvoke. Answer: B, E QUESTION 27: You are creating a Windows Form that includes custom print functionality. You need to ensure that exactly four pages are printed. What should you do? In the BeginPrint event handler, reset a counter. Increment the counter each time that the PrintPage event handler is invoked. On the fourth invocation, set the PrintPageEventArg.HasMorePages property to False. In the BeginPrint event handler, reset a counter. Increment the counter each time that the PrintPage event handler is invoked. On the fourth invocation, set the PrintPageEventArg.Cancel property to True. In the PrintPage event handler, ensure that the page will render only if the PrintPageEventArg.HasMorePages property is set to True. In the PrintPage event handler, ensure that the page will render only if the PrintPageEventArg.Cancel property is set to False. Answer: A QUESTION 28: You are creating a Windows user control named UrlRequest. UrlRequest contains a ComboBox control named cboUrl and a Button control named btnGo. When the user clicks btnGo, you want the UrlRequest control to provide notification that the value of cboUrl changed. You need to implement the notification functionality. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.) Create a public event named UrlRequested and a property named Url for your control that returns the Url value of cboUrl. Change the Modifiers property of btnGo to Public. Add a DefaultEvent attribute to UrlRequest that uses the btnGo_Click event as an argument. Change the Modifiers property of cboUrl to Public. Raise the UrlRequest event in the Click event handler for btnGo. Answer: A, E QUESTION 29: You are creating a shaped Windows Form. The shape and background for the form are available in a bitmap file named Background.bmp. The FormBorderStyle property is set to None and the BackgroundImage property is set to background.bmp. Hovewer, when the application runs, the entire image including all of the background is visible and the form still appears to be rectangular. You need to configure the form so that it takes the shape of the bitmap file without the background. What should you do? Set the BackgroundImageLayout property to None. Set the BackColor property of the form to the background color of Background.bmp. Set the Opactiy property of the form to 0%. Set the TransparencyKey property of the form to the background color of Background.bmp. Answer: D. QUESTION 30: You are creating a data-entry application that uses many TextBox controls. Each control requires special validation logic. You need to ensure an extended version of the standard Windows Forms TextBox control that has the validation logic built into the control. You start by creating a new Windows Control Library project. What should you do? Add a TextBox control to the control design surface, and add properties and methods as required. In the code, change the class to derive from the UserControl class, and add properties and methods as required. In the code, change the class to derive from the TextBox class, and add properties and methods as required. In the code, change the class to derive from the Control base class, and add properties and methods as required. Answer: C QUESTION 31: Your create a Windows user control named EmployeeData. You want to provide design-time layout support for EmployeeData to that it will easily align with other controls on the form. You create a class named SnapLineDesigner that inherits from the System.Windows.Forms.Design.ControlDesigner class. You add a Designer attribute to the EmployeeData class and pass in snapLineDesigner as the designer TypeName parameter. You need to provide the design-time layout support for EmployeeData. What should you do? In the constructor of EmployeeData, add items to the SnapLines collection of EmployeeData. In the constructor of EmployeeData, add items to the SnapLines colleciton of SnapLineDesigner. In the constructor of SnapLineDesigner, add items to the SnapLines collection of EmployeeData. In the constructor of SnapLineDesigner, add items to the SnapLines collection of SnapLineDesigner. Answer: D QUESTION 32: Exhibit: You are building a custom extended button control. This control handles its own painting by displaying a particular metric value in the upper right corner of the button, as shown in the exhibit. You test this feature and verify that it works correctly. You also want the displayed value to be updated in real time as the user uses the application. You override the Onpaint method of the control to raise the Paint event when required. Your project compiles and builds with no problems, but the control does not paint itself correctly. You need to ensure that the control paints itself correctly. What should you do? Call the base OnPaint method of the class from within your OnPaint method. Raise the Paint event handler from within the OnPaint method. Call the OnPaint method of the base class from within the Paint event. Use the DefualtEvent attribute on you control class to specify that events will correctly ripple down the event chain from the base class to your current instance. Answer: A QUESTION 33: You are customizing a Windows Form. You need to add an input control that provides AutoComplete suggestions to the user as the user types. Which two controls can you use to achieve this goal? (Each correct answer presents a complete solution. Choose two.) TextBox control set to SingleLine mode TextBox control set the MultiLine mode ComboBox control RichTextBox control MaskedTextBox control Answer: A, C QUESTION 34: You are creating a Windows Forms application to retrieve and modify data. Depending on the installation, the data source can .. a Microsoft Access database or a Microsoft SQL Server 2000 or later database. You need to ensure that your application accesses data by automatically using the data provider that is optimized for the data source. What should you do? Use the ODBC data provider classes. Use the OLE DB data provider classes. Use the SQL Server data provider classes. Use the DbProviderFactory class and related classes. Answer: D QUESTION 35: You are creating a Windows Forms application. The application executes a stored procedure that takes several seconds to complete. The procedure is invoked to populate a SqlDataReader object. You need to ensure that the application remains responsive to the user while the stored procedure is executing. What should you do? Use the SqlCommand.BeginExecuteReader method to call the stored procedure. Retrieve results by using the EndExecuteReader method. Use the SqlCommand.ExecuteReader method. Set the behavior parameter of this method to CommandBehavior.SequentialAccess. Create and bind a SqlDependency object to SqlCommand object. Call the SqlCommand.ExecuteReader method. Associate an OnChanged event handler with the SqlDependency object. Gather results in the OnChanged event handler method. Set the Notification property of a SqlCommand object to a SqlNotificationRequest object. Call the SqlCommand.ExecuteReader method. Gather results on a background thread. Answer: A QUESTION 36: You are creating a Windows Forms application that targets Microsoft Windows 2000 or later. You need to configure your Setup application for conditional installation. Which part or parts of a Setup application can be configured for conditional installation based on the operating system? (Choose all that apply.) primary output of a project registry keys and values file type associations user interface dialog boxes custom actions Answer: B, C QUESTION 37: A Windows Forms application loads an XmlDocument from a file named books.xml. You need to validate the XML against a schema that is contained in the books.xsd file when the XML loads. What should you do? Associate the schema file with an XmlReader. Load the XmlDocument by using the XmlReader. Add the schema to the Schemas property of the XmlDocument. Call the Load method of the XmlDocument by setting the filename parameter to books.xsd. Call the Load method of the XmlDocument by setting the filenmae parameter to books.xsd, and then call the Loat method by setting the filename parameter to books.xml. Call the Load method of the XmlDocument by setting the filename parameter to books.xsd. Programatically add the attriubte xsi:schemaLocation to the root node. Set the value of this attribute to books.xsd. Answer: A QUESTION 38: You are creating a Windows Forms setup application. The default user interface does not meet your needs. You want to provide an additional dialog box that includes two check boxes during the install process. You want the check boxes to give users the option to install two large Help files named Certkiller 1 and Certkiller 2 during the installation process. You need to customize the interface to meet your needs. Which three actions should you perform? (Each correct answer presents part of the solution. Choose three.) Create the dialog box and the logic for the dialog box in a separate project. Compile the project into an executable, and add the executable to the setup project. In the User Interface Editor, add a Checkboxes dialog box to the Start node of the user interface tree. In the Custom Actions Editor to add the dialog box executable for the setup application to the install node. In the Properties window for your setup project, set the PreBuildEvent property to call a command line to display the dialog box. In the File System Editor, set the Condition property for Certkiller 1 to the value of the Checkbox1Property propert. Set the condition property for Certkiller 2 to the value of the Checkbox2Property property. Set the Checkbox3Visible and Checkbox4Visible properties of the Checkboxes dialog box to False. Answer: B, E, F QUESTION 39: You are testing an installation package for a Windows Forms application. You notice that the installed application will not run on client computers that do not have the .Net Framework installed. You need to ensure that when a user installs the application on his or her client computer, the .Net Framework is also installed. What should you do? Select the .Net Framework in the Dependencies property value in the project's property grid. Verify that the .Net Framework redistributable package check box is selected under the Prerequisites button on the setup property pages. Add the .Net Framework redistributable package to the setup project in the File System Editor. Create a Custom Actions Editor that copies the .Net Framework redistributable package to the application's root directory. Answer: B QUESTION 40: You create a Windows-based application that requires the use of a COM component. You need to create a ClickOnce deployment package to distribute the application from an Internet Web site. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.) Set the Isolated property of the COM component references in the application project to False. Set the Isolated property of the COM component references in the application project to True. Verify that the user is using Microsoft Windows XP. Verify that the user is using Microsoft Windows 2000. Assign RegistryPermission to the application. Answer: B, C QUESTION 41: You are creating a setup project. You want to add functionality that will execute only if the setup project is executed by an administrative user. You need to configure features of your installation package to execute only when the installation is run by an administrative user. Which setup project editor supports this functionality by default? File System Editor Registry Editor User Interface Editor Custom Action Editor Answer: C QUESTION 42: You are creating a multiple-document interface (MDI) Windows Forms application that contains an MDI parent form and an MDI child form. You add a MenuStrip control to the parent form and a MenuStrip control to the child form. You add a top-level menu item labeled File to each menu. You then add different submenu items to each menu. When a child window is visible, the application should display a single top-level File menu that contains the combined set of submenu items. You need to set form properties so that the menus combine correctly. What should you do? Set the MergeAction property of the child form's File menu item to MatchOnly. Set the MergeAction property of the child form's submenu items to Insert. Set the MergeAction property of the parent form's File menu item to MatchOnly. Set the MergeAciton property of the parent form's submenu items to Insert. Set the MergeAction property of the child form's File menu item to Insert. Set the MergeAction property of the child form's submenu items to MatchOnly. D. Set the MergeAction property of the parent form's File menu item to Insert. Set the MergeAction property of the parent form's submenu items to MatchOnly. Answer: A QUESTION 43: You are creating a complex data-entry Windows Forms application. The application allows users to move text between text boxes by using drag-and-drop operations. Your company also has other data-entry applications. You need to ensure that users can perform similar drag-and-drop operations between the different applications. What should you do? Ensure that the AllowedEffect property in each application includes the DragDropEffects.Link settings. Ensure that the Effect property in each application includes the DragDropEffects.Link setting. Ensure that the Effect property in the drag source application includes the DragDropEffects.Link setting, and the AllowEffect property in drop target application is set to DragDropEffects.Copy. Ensure that the Effect and AllowEffect properties in each application includes the DragDropEffects.Copy setting. Answer: D QUESTION 44: You are working with a Windows Forms application that uses the Application.Settings features... You need to perform certain processing actions when user settings are changed at run time. Which two events should you handle to achieve this goal? (Each correct answer presents part of the solution. Choose two.) SettingChanging PropertyChanged StateChange SettingsLoaded Change Answer: A, B QUESTION 45: You are creating the printing components of an application for your company. A security requirement states that users can choose only local printers attached to their computers. Browsing network printers is prohibited. You need to disable a user's ability to browse the network for printers when using the PageSetup dialog box. What should you do? Use the ShowNetwork property of the PageSetupDialog component to remove the Network button from the Page Setup dialog box. Use the PrinterSettings.PrinterName property to explicitly refer to the approved printers. Use the PrinterSettings.PaperSource property to explicitly refer to the approved paper sources. Set the AllowPrinter property of the PageSetupDialog component to False. Use the PageSettings.PaperSource property of the PageSetupDialog component to explicitly refer to the approved paper sources. Answer: A QUESTION 46: You are creating a Windows Form application. You add a new form named ClientNameDialog that will be used as a custom dialog box. The form contains custom control name btnOk, another button control named btnCancel, and a text box control named txtName. You need to notify the application's startup form which button was clicket when the dialog box is closed. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.) Use the ShowDialog method to display an instance of ClientNameDialog. Use the Show method and pass the current form as a parameter to display an instance of ClientNameDialog. Using the DialogResult property of the dialog box instance, indicate which button the user clicks on ClientNameDialog. Using the AcceptButton property of the dialog box instance, indicate which button the user clicks on ClientNameDialog. Answer: A, C QUESTION 47: You are creating an application named Certkiller App1. You use ClickOnce deployment to distribute Certkiller App1.exe and multiple Assemblies. Some users require only some of the functionality in Certkiller App1. You need to limit the size of the initial download of the application. You also need to ensure that users can download the assemblies on demand. Which three actions should you perform? (Each correct answer presents part of the solution. Choose three.) Mark each dependency in Certkiller App1.exe.manifes as optional. Mark each dependency in Certkiller App1.application as optional. Create an event handler for the AppDomain.ResourceResolve event named ResolveAssembly. Create an event handler for the AppDomain.AssemblyLoad event named ResolveAssembly. In the ResolveAssembly event handler, set the ApplicationDeployment.CurrentDeployment.ActivationUri property to the location of your required assembly. In the ResolveAssembly event handler, call ApplicationDeployment.DownloadFiles and pass in the name of the assembly you want. Answer: A, C, F QUESTION 48: You are creating a Windows Forms application that implements a master/detail form by using two DataGridView controls. You populate a dataset with a master table and a details table. You set the DataSource property of the master DataGridView control to the dataset. You set the DataMember property to the name of the master table. You also set the DataSource property of the details DataGridView control to the dataset. You need to ensure that the details DataGridView control displays only the child rows of the selected master row. What should you do? A. Add a foreign key constraint to the dataset. Set the DataMember property of the child DataGridView control to the name of the foreign key constraint. B. Define a data relation between the master table and details table in the dataset. Set the DataMember property of the child DataGridView to the name of the data relation. C. Add a foreign key constraint to the dataset. Set the DataMember property of the child DataGridView control to the name of the details table. D. Define a data relation between the master table and details table in the dataset. Bind the details DataGridView control to the dataset. Set the DataMember property of the child DataGridView control to the name of the details table. Answer: B QUESTION 49: You are creating a Windows Form that includes printing functionality to print an image of the form. A helper function with the following signature creates a bitmap of the current form. Function CreateFormImageBitmap(ByVal graphic As Graphics) As _ Bitmap You need to implement the PrintPage event handler to call the helper function and draw the image onto the print document. Which code segment should you use? A. Dim g As Graphics = e.Graphics Dim formImageBitmap As Bitmap = CreateFormImageBitmap(g) g.DrawImage(formImageBitmap, e.MarginBounds) B. Dim g As Graphics = Me.CreateGraphics() Dim formImageBitmap As Bitmap = CreateFormImageBitmap(g) g.DrawImage(formImageBitmap, g.ClipBounds) g.Dispose() C. Dim g As Graphics = Me.CreateGraphics() Dim formImageBitmap As Bitmap = CreateFormImageBitmap(e.Graphics) g.DrawImage(formImageBitmap, g.ClipBounds) g.Dispose() D. Dim g As Graphics = Me.CreateGraphics() Dim formImageBitmap As Bitmap = CreateFormImageBitmap(g) e.Graphics.DrawImage(formImageBitmap, e.MarginBounds) g.Dispose() Answer: D QUESTION 50: Your law firm uses a custom application to create and print legal documents. Currently, users can print any portion of a document that they want from the application by using the options in the Print dialog box. This Print dialog box was implemented by using the PrintDialog component. New security and auditing rules state that the application must implement a business rule that requires users to print documents in their entirety. Printing only portions of a document is prohibited. You need to modify the PrintDialog component named printDlg to enforce the business rule when a user prints. You must implement this rule with the minimum amount of impact to users. What should you do? A. Set the PrintDialog component to printDlg.PrinterSettings.PrintRange = PrintRange.AllPages. Call the printDlg.Reset method when the Print dialog box is closed. Configure the following settings for the PrintDialog component.printDlg.AllowSomePages = FalseprintDlg.AllowSelection = FalseprintDlg.AllowCurrentPage = False Create a warning message that displays if the user selects the Pages option in the Print dialog box to try to print a subset of a document. Use the following settings to set the full document to print.printDlg.PrinterSettings.FromPage = printDlg.PrinterSettings.MinimumPage printDlg.PrinterSettings.ToPage = printDlg.PrinterSettings.MaximumPage Answer: C QUESTION 51: You are customizing a Windows Form to update a database asynchronously by using an instance of a BackgroundWorker component named bgwExecute. You start the component by using the following code. Private Sub StartBackgroundProcess() AddHandler bgwExecute.DoWork, _ New DoWorkEventHandler(AddressOf WorkHandler) AddHandler bgwExecute.RunWorkerCompleted, _ New RunWorkerCompletedEventHandler(AddressOf _ CompletedHandler) AddHandler bgwExecute.ProgressChanged, _ New ProgressChangedEventHandler(AddressOf ProgressChanged) bgwExecute.RunWorkerAsync() End Sub If the UpdateDB method that is called by the BackgroundWorker component returns the value False, you need to display a message box to the user that indicates that the update failed. Which code segment should you use? Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) If Not UpdateDB() Then MessageBox.Show("Update failed") End If End Sub Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) If Not UpdateDB() Then MessageBox.Show("Update failed") End If End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) e.Result = UpdateDB() End Sub Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) If Not CBool(e.Result) Then MessageBox.Show("Update failed") End If End Sub D. Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) e.Result = UpdateDB() End Sub Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) If Not CBool(e.Result) Then bgwExecute.ReportProgress(0) End If End Sub Sub ProgressChanged(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) If e.ProgressPercentage = 0 Then MessageBox.Show("Update failed") End If End Sub Answer: C QUESTION 52: You are creating a Windows Forms application. You implement the asynchronous design pattern by using a delegate named DataUpdateHandler. DataUpdateHandler executes a method named DataUpdater. You create an instance of the DataUpdateHandler that has the variable name Updater. DataUpdater uses a DataSet class as a parameter and returns an integer value that indicates the number of rows that have been updated. You need to use a method named DisplayResults to display the results when the database update is complete. Which code segment should you use? Dim result As IAsyncResult = Updater.BeginInvoke(mData, Nothing, _ Nothing) '... Dim value As Integer = result.AsyncState DisplayResults(value) Dim result As IAsyncResult = Updater.BeginInvoke(mData, Nothing, _ Nothing) '... Dim value As Integer = Updater.EndInvoke(result) DisplayResults(value) Dim result As IAsyncResult = Updater.BeginInvoke(mData, Nothing, _ "DisplayResults") '... Updater.EndInvoke(result) D. Dim result As IAsyncResult = Updater.BeginInvoke(mData, Nothing, _ "DataUpdater") '... Updater.EndInvoke(result) Answer: B QUESTION 53: You want to execute an event handler asynchronously from a Windows Form. You need to write code that uses the BackgroundWorker component named bgwExecute to execute the WorkHandler method. Which code segment should you use? Dim work As New EventHandler(AddressOf WorkHandler)bgwExecute.RunWorkerAsync(work) Dim tsBackground As New ThreadStart(AddressOf WorkHandler)bgwExecute.ReportProgress(0, tsBackground) Dim tsBackground As New ThreadStart(AddressOf WorkHandler)bgwExecute.RunWorkerAsync(tsBackground) AddHandler bgwExecute.DoWork, AddressOf WorkHandlerbgwExecute.RunWorkerAsync() Answer: D QUESTION 54: You are customizing a Windows Form to asynchronously update a database. You need to ensure that the form displays a message box to the user that indicates the success or failure of the update. Which three code segments should you use? (Each correct answer presents part of the solution. Choose three.) A. Private Sub StartBackgroundProcess() AddHandler bgwExecute.DoWork, AddressOf WorkHandler AddHandler bgwExecute.RunWorkerCompleted, AddressOf CompletedHandler bgwExecute.RunWorkerAsync() End Sub B. Private Sub StartBackgroundProcess() AddHandler bgwExecute.ProgressChanged, AddressOf CompletedHandler Dim tsBackground As New ThreadStart(AddressOf WorkHandler) bgwExecute.RunWorkerAsync(tsBackground) End Sub C. Private Sub StartBackgroundProcess() AddHandler bgwExecute.RunWorkerCompleted, AddressOf CompletedHandler Dim tsBackground As New ThreadStart(AddressOf WorkHandler) bgwExecute.RunWorkerAsync(tsBackground) End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) ... e.Result = True End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) ... bgwExecute.ReportProgress(100, True) End Sub Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) Dim result As Boolean = CBool(e.Result) If result Then MessageBox.Show("Update was successful") Else MessageBox.Show("Update failed") End If End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) Dim result As Boolean = CBool(e.UserState) If result Then MessageBox.Show("Update was successful") Else MessageBox.Show("Update failed") End If End Sub Answer: A,D,F QUESTION 55: You are creating a Windows Forms application. You create a System.Threading.Semaphore instance in the application by using the following code. Dim ThreadPool As Semaphore = New Semaphore(0, 3) ... ThreadPool.Release(4) What does this code do? Sets the internal counter for the semaphore to 4. Sets the internal counter for the semaphore to 0. Throws a SemaphoreFullException. Throws a ThreadAbortException. Answer: C QUESTION 56: You are creating a Windows Forms application. The application uses a SqlCommand object named cmd. The cmd object executes the following stored procedure. CREATE PROCEDURE GetPhoneList AS BEGIN SELECT CompanyName, Phone FROM Customers SELECT CompanyName, Phone FROM Suppliers END You need to add all returned rows to the ListBox control named lstPhones. Which code segment should you use? Dim rdr As SqlDataReader = cmd.ExecuteReader() Do While rdr.Read() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1))) End While Loop While rdr.NextResult() Dim rdr As SqlDataReader = cmd.ExecuteReader() While rdr.Read() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1))) End While Dim rdr As SqlDataReader = cmd.ExecuteReader() While rdr.NextResult() While rdr.Read() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1))) End While End While Dim rdr As SqlDataReader = cmd.ExecuteReader() While rdr.NextResult() lstPhones.Items.Add((rdr.GetString(0) + ControlChars.Tab + rdr.GetString(1))) End While Answer: A QUESTION 57: A Windows Forms application contains the following code segment. Dim SQL As String = "SELECT EmployeeID, LastName, FirstName FROM Employees" Dim da As New SqlDataAdapter(SQL, connStr) Dim dt As New DataTable() da.MissingSchemaAction = MissingSchemaAction.AddWithKey Dim bld As New SqlCommandBuilder(da) da.Fill(dt) The application allows the user to add rows to the data table. The application will propagate these additions to the database. If the addition of any row fails, the other rows must still be added. The code must log how many new rows failed to be added. You need to propagate the additions to the database and log a failed count. Which code segment should you use? da.ContinueUpdateOnError = True da.Update(dt) Dim dtErrors As DataTable = dt.GetChanges(DataRowState.Unchanged) Trace.WriteLine((dtErrors.Rows.Count.ToString() + " rows not added.")) da.ContinueUpdateOnError = False da.Update(dt) Dim dtErrors As DataTable = dt.GetChanges(DataRowState.Unchanged) Trace.WriteLine((dtErrors.Rows.Count.ToString() + " rows not added.")) da.ContinueUpdateOnError = True da.Update(dt) Dim rows As DataRow() = dt.GetErrors() Trace.WriteLine((rows.Length.ToString() + " rows not added.")) da.ContinueUpdateOnError = False da.Update(dt) Dim rows As DataRow() = dt.GetErrors() Trace.WriteLine((rows.Length.ToString() + " rows not added.")) Answer: C QUESTION 58: A Windows Forms application reads the following XML file. Gambardella, Matthew XML Developer's Guide Ralls, Kim Midnight Rain The form initialization loads this file into an XmlDocument object named docBooks. You need to populate a ListBox control named lstBooks with the concatenated book ID and title of each book. Which code segment should you use? A. Dim elements As XmlNodeList = docBooks.GetElementsByTagName("book") Dim node As XmlElement For Each node In elements Dim s As String = node.GetAttribute("id") + " - " s = s + node.SelectSingleNode("title").InnerText lstBooks.Items.Add(s) Next node Dim elements As XmlNodeList = docBooks.GetElementsByTagName("book") Dim node As XmlElement For Each node In elements Dim s As String = node.SelectSingleNode("id").ToString() + " - " s = s + node.GetAttribute("title") lstBooks.Items.Add(s) Next node Dim elements As XmlNodeList = docBooks.GetElementsByTagName("book") Dim node As XmlElement For Each node In elements Dim s As String = node.GetAttribute("id") + " - " s = s + node.SelectSingleNode("title").Value lstBooks.Items.Add(s) Next node Dim elements As XmlNodeList = docBooks.GetElementsByTagName("book") Dim node As XmlElement For Each node In elements lstBooks.Items.Add(node.InnerXml) Next node Answer: A QUESTION 59: You create an application that provides accessibility features. Your standard forms display a background image. When the user selects Use High Contrast in the Accessibility Options in Control Panel, you want this image to be removed. You need to add an event to handle this accessibility setting change. Which event should you use? Me.StyleChanged SystemEvents.UserPreferenceChanged Me.ChangeUICues SystemEvents.DisplaySettingsChanged Answer: B QUESTION 60: You are localizing a Windows Forms application. You put all error message strings into a resource file named ErrorMessages.resx. When the resource file is compiled, a strongly typed resource class is generated. You need to retrieve an error message named CatastrophicErr from the exception-handling code. Which code segment should you use? Dim s As String = My.Resources.ErrorMessages.CatastrophicErr Dim s As String = _Settings.Default("ErrorMessages_CatastrophicErr").ToString() Dim si As New StringInfo("ErrorMessages.CatastrophicErr")Dim s As String = si.String Dim a As [Assembly] = [Assembly].GetExecutingAssembly()Dim stream As Stream = _ a.GetManifestResourceStream("ErrorMessages.CatastrophicErr")Dim sr As New StreamReader(stream)Dim s As String = sr.ReadToEnd() Answer: A QUESTION 61: You are creating a Windows Form. You add a TableLayoutPanel control named pnlLayout to the form. You set the properties of pnlLayout so that it will resize with the form. You need to create a three-column layout that has fixed left and right columns. The fixed columns must each remain 50 pixels wide when the form is resized. The middle column must fill the remainder of the form width when the form is resized. You add the three columns in the designer. Which code segment should you use to format the columns at run time? A. pnlLayout.ColumnStyles.Clear() pnlLayout.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 50.0F)) pnlLayout.ColumnStyles.Add(New ColumnStyle(SizeType.AutoSize, 100.0F)) pnlLayout.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 50.0F)) pnlLayout.ColumnStyles(0).Width = 50.0F pnlLayout.ColumnStyles(0).SizeType = SizeType.Absolute pnlLayout.ColumnStyles(2).Width = 50.0F pnlLayout.ColumnStyles(2).SizeType = SizeType.Absolute pnlLayout.ColumnStyles(0).Width = 50.0F pnlLayout.ColumnStyles(0).SizeType = SizeType.Absolute pnlLayout.ColumnStyles(1).Width = 100.0F pnlLayout.ColumnStyles(1).SizeType = SizeType.AutoSize pnlLayout.ColumnStyles(2).Width = 50.0F pnlLayout.ColumnStyles(2).SizeType = SizeType.Absolute pnlLayout.ColumnStyles.Clear() pnlLayout.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 50.0F)) pnlLayout.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 100.0F)) pnlLayout.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 50.0F)) Answer: D QUESTION 62: You are customizing a Windows Form. The form includes a menu that has several ToolStripMenuItem controls. An event handler is configured to handle the Click event for all ToolStripMenuItem controls. The event handler has the following signature. Private Sub mnu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) The form class includes a method that has the following signature. Private Sub LogClick(ByVal ctlName As String) You need to add code so that when a user clicks a ToolStripMenuItem control, the mnu_Click method calls the LogClick method. The LogClick method must be called with the ctlName parameter set to the menu text in the ToolStripMenuItem control. Which code segment should you use? Dim mnuItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)LogClick(mnuItem.Text) LogClick(e.ToString()) LogClick(Me.Text) Dim mnuItem As ToolStripMenuItem = CType(Me.GetContainerControl(), ToolStripMenuItem)LogClick(mnuItem.Text) Answer: A QUESTION 63: You are creating a Windows Form that includes a TextBox control named txtDate. When a user right-clicks within the text box, you want the application to display a MonthCalendar control. You need to implement a context menu that provides this functionality. What should you do? A. Add the following code to the form initialization. Dim cal As New MonthCalendar()Dim mnuContext As New ContextMenuStrip()Dim host As New ToolStripControlHost(mnuContext)txtDate.ContextMenuStrip = mnuContext Add the following code to the form initialization.Dim mnuContext As New ContextMenuStrip()Dim cal As New MonthCalendar()Dim host As New ToolStripControlHost(cal)mnuContext.Items.Add(host)txtDate.ContextMenuStrip = mnuContext Add the following code to the form initialization.Dim ctr As New ToolStripContainer()Dim cal As New MonthCalendar()ctr.ContentPanel.Controls.Add(cal)txtDate.Controls.Add(ctr)Add a MouseClick event handler for the TextBox control that contains the following code.If e.Button = MouseButtons.Right Then txtDate.Controls(0).Show()End If Add a MouseClick event handler for the TextBox control that contains the following code.If e.Button = MouseButtons.Right Then Dim mnuContext As New ContextMenuStrip() Dim cal As New MonthCalendar() Dim host As New ToolStripControlHost(cal) mnuContext.Items.Add(host) txtDate.ContextMenuStrip = mnuContextEnd If Answer: B QUESTION 64: You are customizing a Windows Form. When the user clicks any button, you want the application to log information about the users actions by calling a method with the following signature. Public Sub ctl_Click(ByVal sender As Object, ByVal e As EventArgs) You want the form to invoke this method when any Button control is clicked and only when a Button control is clicked. You need to modify the form to invoke this method without interfering with the existing operations of the application. What should you do? Add the following code to the form initialization. Dim ctl As Control For Each ctl In Me.Controls If TypeOf ctl Is Button Then AddHandler ctl.Click, AddressOf ctl_Click End If Next ctl Add the following code to the form initialization. AddHandler Me.Click, AddressOf ctl_Click Use the Properties dialog box to set the Click event for each Button control on the form to the ctl_Click method. Use the Properties dialog box to set the Click event of the form to the ctl_Click method. Answer: A QUESTION 65: You are creating a custom control that displays an image in the background. You notice that when the control is resized, the background image flickers while the control is repeatedly repainted. You need to eliminate the background image flicker. Which three code segments should you use? (Each correct answer presents part of the solution. Choose three.) Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True) Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) Me.SetStyle(ControlStyles.UserPaint, True) Me.SetStyle(ControlStyles.ResizeRedraw, True) Me.SetStyle(ControlStyles.Opaque, True) Answer: A,C,D QUESTION 66: You are creating a custom Windows Forms control. On the background of the control, an ellipse completely filled with a colored gradient is drawn. The bounds for the ellipse are equal to the bounds for the control. The control must correctly repaint itself in all situations. You need to include the drawing of the ellipse in the OnPaint event handler for the custom control. Which code segment should you use? Dim linearGradientBrush = New LinearGradientBrush( _ Me.ClientRectangle, startGradient, endGradient, 45) e.Graphics.FillEllipse(linearGradientBrush, e.ClipRectangle) Dim linearGradientBrush = New LinearGradientBrush( _ New Point(Me.Left, Me.Top), New Point(Me.Right, Me.Bottom), _ startGradient, endGradient) e.Graphics.FillEllipse(linearGradientBrush, e.ClipRectangle) Dim linearGradientBrush = New LinearGradientBrush( _ New Rectangle(Me.Left, Me.Top, Me.Width, Me.Height), _ startGradient, endGradient, 45, True) e.Graphics.FillEllipse(linearGradientBrush, _ Me.Left, Me.Top, Me.Width, Me.Height) Dim linearGradientBrush = New LinearGradientBrush( Me.ClientRectangle, startGradient, endGradient, 45) e.Graphics.FillEllipse(linearGradientBrush, Me.ClientRectangle) Answer: D QUESTION 67: You are creating a Windows Forms application that prints reports. The application uses the PrintDocument control to print the report and the PrintPreviewDialog control to preview reports as shown in the following code segment. streamToPrint = New StreamReader("FileToPrint.txt") Try Dim pd As New PrintDocument() AddHandler pd.PrintPage, AddressOf pd_PrintPage Dim ppd As New PrintPreviewDialog() ppd.Document = pd ppd.ShowDialog() Finally streamToPrint.Close() End Try When a report is printed by using the Print method on the PrintDocument class, the output is correct. When the report is previewed by using the Print Preview dialog box, the output is correct. However, when the report is printed by using the Print button in the Print Preview dialog box, a single blank page is produced. You need to ensure that the output is correct when the Print button in the Print Preview dialog box is used. What should you do? In the event handler for the ppd.Click event, set the position of the streamToPrint.BaseStream property to 0. In the event handler for the ppd.PrintPreviewControl.Click event, set the position of the streamToPrint.BaseStream property to 0. In the event handler for the pd.PrintPage event, set the position of the streamToPrint.BaseStream property to 0. In the event handler for the pd.BeginPrint event, set the position of the streamToPrint.BaseStream property to 0. Answer: D QUESTION 68: You are creating a Windows Forms application. Initialization code loads a DataSet object named ds that includes a table named Users. The Users table includes a column named IsManager. You need to bind the IsManager column to the Checked property of a check box named chkIsManager. Which code segment should you use? chkIsManager.DataBindings.Add("Checked", ds, "Users.IsManager") chkIsManager.DataBindings.Add("Checked", ds, "IsManager") chkIsManager.Text = "{Users.IsManager}"chkIsManager.AutoCheck = True Me.DataBindings.Add("chkIsManager.Checked", ds, "Users.IsManager") Answer: A QUESTION 69: A Windows Forms application contains the following code segment. Dim SQL As String = "SELECT OrderID, ProductID, UnitPrice, Quantity FROM [Order Details]" Dim da As New SqlDataAdapter(SQL, connStr) Dim dt As New DataTable() da.Fill(dt) You need to add a new column to the data table named ItemSubtotal. The ItemSubtotal column must contain the value of the UnitPrice column multiplied by the value of the Quantity column. Which code segment should you use? A. Dim col As New DataColumn("ItemSubtotal") col.DataType = GetType(Decimal)col.Expression = "UnitPrice * Quantity"dt.Columns.Add(col) dt.Compute("UnitPrice * Quantity", "ItemSubtotal") Dim col As New DataColumn("ItemSubtotal") col.DataType = GetType(Decimal) dt.Columns.Add(col) dt.Compute("UnitPrice * Quantity", "ItemSubtotal") D. Dim col As New DataColumn("ItemSubtotal") col.DataType = GetType(Decimal) col.DefaultValue = "UnitPrice * Quantity"dt.Columns.Add(col) Answer: A QUESTION 70: You are creating a Windows Forms application. The application loads a data table named dt from a database and modifies each value in the data table. You add the following code. (Line numbers are included for reference only.) 01 Dim row As DataRow 02 For Each row In dt.Rows 03 Dim col As DataColumn 04 For Each col In dt.Columns 05 06 Trace.WriteLine(str) 07 Next col 08 Next row You need to format the string named str to show the value of the column at the time the data is loaded and the current value in the column. Which code segment should you add at line 05? Dim str As String = String.Format("Column was {0} is now {1}", row(col), row(col, DataRowVersion.Current)) Dim str As String = String.Format("Column was {0} is now {1}", row(col, DataRowVersion.Default), row(col)) Dim str As String = String.Format("Column was {0} is now {1}", row(col), row(col, DataRowVersion.Proposed)) Dim str As String = String.Format("Column was {0} is now {1}", row(col, DataRowVersion.Original), row(col)) Answer: D QUESTION 71: You are creating a Windows Forms application that includes the database helper methods UpdateOrder and UpdateAccount. Each method wraps code that connects to a Microsoft SQL Server 2005 database, executes a Transact-SQL statement, and then disconnects from the database. You must ensure that changes to the database that result from the UpdateAccount method are committed only if the UpdateOrder method succeeds. You need to execute the UpdateAccount method and the UpdateOrder method. Which code segment should you use? A. Using ts As New TransactionScope() UpdateOrder() UpdateAccount() ts.Complete()End Using Using ts1 As New TransactionScope() UpdateOrder() Using ts2 As New TransactionScope(TransactionScopeOption.RequiresNew) UpdateAccount() ts2.Complete() End Using ts1.Complete() End Using ts1.Complete(); Using ts1 As New TransactionScope() UpdateOrder() Using ts2 As New TransactionScope(TransactionScopeOption.RequiresNew) UpdateAccount() ts2.Complete() End Using ts1.Complete()End Using D. Using ts As New TransactionScope(TransactionScopeOption.RequiresNew) UpdateOrder() End Using Using ts As New TransactionScope(TransactionScopeOption.Required) UpdateAccount() ts.Complete() End Using Answer: A QUESTION 72: You are customizing a Windows Form to use a BackgroundWorker component named bgwExecute. bgwExecute performs a database operation in an event handler named WorkHandler. You need to ensure that users can see the progress of the database operation by viewing a progress bar named pbProgress. You want the progress bar to appear when the database operation is 50 percent complete. Which code segment should you use? A. Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler bgwExecute.RunWorkerAsync() End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) bgwExecute.ReportProgress(50) End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentage End Sub Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler Dim t As New ThreadStart(AddressOf WorkHandler) bgwExecute.RunWorkerAsync(t) End Sub Sub WorkHandler() bgwExecute.ReportProgress(50) End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentage End Sub Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler Dim t As New Thread(New ThreadStart(AddressOf WorkHandler)) bgwExecute.RunWorkerAsync(t) End Sub Sub WorkHandler() bgwExecute.ReportProgress(50) End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentage End Sub D. Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.DoWork, AddressOf WorkHandler AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler bgwExecute.RunWorkerAsync() End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) bgwExecute.ReportProgress(50) End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentage End Sub Answer: D QUESTION 73: You want to execute an event handler asynchronously from a Windows Form. You need to execute a method named WorkHandler by using an instance of the BackgroundWorker component named bgwExecute. Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.) Dim work As New EventHandler(AddressOf WorkHandler) Dim work As New ThreadStart(AddressOf WorkHandler) AddHandler bgwExecute.DoWork, AddressOf WorkHandler bgwExecute.RunWorkerAsync() bgwExecute.RunWorkerAsync(work) Answer: C,D QUESTION 74: You are customizing a Windows Form to update a database asynchronously in a method named WorkHandler. You need to ensure that the form displays a message box to the user that indicates the success or failure of the update. Which code segment should you use? A. Private Sub StartBackgroundProcess() AddHandler bgwExecute.DoWork, AddressOf WorkHandler AddHandler bgwExecute.RunWorkerCompleted, AddressOf CompletedHandler bgwExecute.RunWorkerAsync() End SubPrivate Sub CompletedHandler(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Dim result As Boolean = CType(e.Result, Boolean) If result = True Then MessageBox.Show("Update was successful") Else MessageBox.Show("Update failed") End IfEnd SubPrivate Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) .. '... e.Result = True End Sub B. Private Sub StartBackgroundProcess() AddHandler bgwExecute.ProgressChanged, AddressOf CompletedHandler Dim tsBackground As New ThreadStart(AddressOf WorkHandler) bgwExecute.RunWorkerAsync(tsBackground) End Sub Private Sub ProgressHandler(ByVal sender As Object, ByVal e As ProgressChangedEventArgs) Dim result As Boolean = CType(e.UserState, Boolean) If result = True Then MessageBox.Show("Update was successful") Else MessageBox.Show("Update failed") End If End Sub Private Sub WorkHandler() '... bgwExecute.ReportProgress(100, True) End Sub C. Private Sub StartBackgroundProcess() AddHandler bgwExecute.RunWorkerCompleted, AddressOf CompletedHandler Dim tsBackground As New ThreadStart(AddressOf WorkHandler) bgwExecute.RunWorkerAsync(tsBackground) End Sub Private Sub CompletedHandler(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Dim result As Boolean = CType(e.Result, Boolean) If result = True Then MessageBox.Show("Update was successful") Else MessageBox.Show("Update failed") End IfEnd SubPrivate Sub WorkHandler() '... bgwExecute.ReportProgress(100, True) End Sub D. Private Sub StartBackgroundProcess() AddHandler bgwExecute.DoWork, AddressOf WorkHandler AddHandler bgwExecute.RunWorkerCompleted, AddressOf CompletedHandler bgwExecute.RunWorkerAsync() End SubPrivate Sub CompletedHandler(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Dim result As Boolean = CType(e.Result, Boolean) If result = True Then MessageBox.Show("Update was successful") Else MessageBox.Show("Update failed") End IfEnd SubPrivate Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) '... bgwExecute.ReportProgress(100, True) End Sub Answer: A QUESTION 75: You are creating a Windows Forms application. You want to execute a method named ProcessAmount in the background of the application. The method you want to execute requires that an integer value of 13 is passed. You need to pass an integer value of 13 to a starting background thread. Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.) Dim ts As New ThreadStart(AddressOf ProcessAmount2)Dim t As New Thread(ts, 13) Dim ts As New ParameterizedThreadStart(AddressOf ProcessAmount)Dim t As New Thread(ts) t.Start() t.Start(13) Answer: B,D QUESTION 76: You are creating a Windows Forms application. You add an ErrorProvider component named erpErrors and a DateTimePicker control named dtpStartDate to the application. The application also contains other controls. You need to configure the application to display an error notification icon next to dtpStartDate when the user enters a date that is greater than today's date. Which two action should you perform? (Each correct answer presents part of the solution. Choose two.) For the Validating event of dtpStartDate, create an event handler named VerifyStartDate. For the Validated event of dtpStartDate, create an event handler named VerifyStartDate. In the Properties Window for dtpStartDate, set the value of Error on erpErrors to Date out of range . In VerifyStartDate, call erpErrors.SetError(dtpStartDate, "Date out of range") if the value of dtpStartDate value is greater than today's date. In VerifyStartDate, call erpErrors.SetError(dtpStartDate, null) if the dtpStartDate.Value is greater than today's date. Answer: A, E QUESTION 77: You are customizing a Windows Form. When the user clicks any button, you want the application to log information about the user's actions by calling a method with the following signature. public void ctl_Click(object sender, EventArgs e) You want the form to invoke this method when any Button control is clicked and only when a Button control is clicked. You need to modify the form to invoke this method without interfering with the existing operations of the application. What should you do? Add the following code to the form initialization. foreach (Control ctl in this.Controls) { if (ctl is Button) { ct1.Click += new EventHandler(ct1_Click); } } Add the following code to the form initialization. this.Click += new EventHandler(ct1_Click); Use the Properties dialog box to set the Click event for each Button control on the form to the ctl_Click method. Use the Properties dialog box to set the Click event of the form to the ctl_Click method. Answer: A QUESTION 78: You are localizing a Windows Forms application. You put all error message strings into a resource file named ErrorMessage file. When the resource file is compiled, a strongly typed resource class is generated. You need to retrieve an error message named CatastrophicErr from the exception-handling code. Which code segment should you use? string s= ErrorMessages. CatastrophicErr; string s= Properties.Settings.Default["ErrorMessages_CatastrophicErr"].ToString(); StringInfo si = new StringInfo("ErrorMessages. CatastrophicErr"); string s = si.String; D. Assembly a = Assembly.GetExecutingAssembly(); Stream stream = a.GetManifestRseourceStream("ErrorMessage.CatastrophicErr"); StreamReader sr= new StreamReader(stream); stream s= sr.ReadToEnd(); Answer: A QUESTION 79: A Windows Forms application includes resources that are localized for several languages. You want to view your application when a uses resources that are localized for the French language as spoken in France. This culture is denoted by the culture name fr-FR. You need to test the application by using the resources contained in the satellite assembly. You must not modify the regional settings of your computer. What should you do? Set the following assembly attribute. [assembly: NeutralResourcesLanguage("fr-FR")] Add the following code to the application initialization. RegionInfo ri = new RegionInfo("FR"); Thread. CurrentThread.Name = ri.NativeName; Add the following code to the application initialization. Thread.CurrentThread.CurrentUICulture = new CultuerInfo("fr-FR"); Add the following code to the applicationSettings section of the application configuration file. "fr-FR" Answer: C QUESTION 80: You are creating a custom control that displays an image in the background. You notice that when the control is resized the background image. You need to eliminate the background image flicker. Which three code segments should you use? (Each correct answer presents part of the solution. Choose three.) this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Opaque, true); Answer: A, B, C QUESTION 81: You are creating a custom Windows Forms control. On the background of the control, an ellipse completely filled with a colored gradient is drawn. The bounds for the ellipse are equal to the bounds for the control. The control must correctly repaint itself in all situations. You need to include the drawing of the ellipse in the OnPaint event handler for the custom control. Which code segment should you use? Brush linearGradientBrush = new LinearGradientBrush(e.ClipRectangle, startGradient, endGradient, 45); Brush linearGradientBrush = new LinearGradientBrush( new Point(this.Left, this.Top), new Point(this.Right, this.Bottom), startGradient, endGradient); e.Graphics.FillEllipse(1inearGradientBrush, e.ClipRectangle); Brush linearGradientBrush = new LinearGradientBrush( new Rectangle(this.Left, this.Top, this.Width, this.Height), startGradient, endGradient, 45, true); e.Graphics.FillEllipse(linearGradientBrush, this.Left, this.Top, this. Width, this.Height); Brush linearGradientBrush = new LinearGradientBrush(this.ClientRectangle, startGrafics.FillEllipse(linearGradientBrush, this.ClientRectangle); Answer: D QUESTION 82: Your law firm uses a custom application to create and print legal documents. Currently, users can print any portion of a document that they want from the application by using the options in the Print dialog box. This Print dialog box was implemented by using the PrintDialog component. New security and auditing rules state that the application must implement a business rule that requires users to print documents in their entirety. You need to modify the PrintDialog component named printDlg to enformce the business rule when a user prints. You must implement this rule with the minimum amount of impact to users. What should you do? Set the PrintDialog component to printDlg.PrinterSettings.PrintRange = PrintRange.AllPages. Call the printDlg.Reset method when the Print dialog box is closed. Configure the following settings for the PrintDialog component. printDlg.AllowSomePages = false; printDlg.AllowSelection = false; printDlg.AllowsCurrentPage = false; Create a warning message that display if the user selects the Pages option in the Print dialog box to try to print a subset of a document. Use the following settings to set the full document to print. printerDlg.PrinterSettings.FromPage = printerDlg.PrinterSettings.MinimumPage; printerDlg.PrinterSettings.ToPage = printerDlg.PrinterSettings.MaximumPage; Answer: C QUESTION 83: You are creating a Windows Forms application that prints reports. The application uses the PrintDocument control to print the report and the PrintPreviewDialog control to preview reports as shown in the following code segment. streamToPrint = new StreamReader("..\\..\\FilesToPrint.txt"); try { PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); PrintPreviewDialog ppd =New PrintPreviewDialog(); ppd.Document = pd; ppd.ShowDialog(); } finally { streamToPrint.Close(); } When a report is printed by using the Print method on the PrintDocument class, the output is correct. When the report is previewed by using the Print Preview dialog box, the output is correct. However, when the report is printed by using the Print button in the Print Preview dialog box, a single blank page is produced. You need to ensure that the output is correct when the Print button in the Print Preview dialog box is used. What should you do? In the event handler for the ppd.Click event, set the position of the streamToPrint.BaseStream property to 0. In the event handler for the ppd.PrintPreviewControl.Click event, set the position of the streamToPrint.BaseStream property to 0. In the event handler for the pd.PrintPage event, set the position of the streamToPrint.BaseStream property to 0. In the event handler for the pd.BeginPrint event, set the position of the streamToPrint.BaseStream property to 0. Answer: D QUESTION 84: You are creating a Windows Forms application. Initialization code loads a DataSet object named ds that includes a table named Users. The Users table includes a column named IsManager. You need to bind the IsManager column to the Checked property of a check box named chkIsManager. Which code segment should you use? chkIsManger.DataBindings.Add("Checked".ds "Users.IsManager"); chkIsManger.DataBindings.Add("Checked".ds "IsManager"); chkIsManger.Text = "{Users.IsManager}"; chkIsManager.AutoCheck = true; this.DataBindings.Add("chkIsManager.Checked" , ds, "Users.IsManager"); Answer: A QUESTION 85: A Windows Forms application contains the following code segment. string SQL = @"SELECT OrderID, ProductID, UnitPrice, Quantity FROM [Order Details]"; SqlDataAdapter da = new SqlDataAdapter(SQL, connStr); Data Table dt = new Data Table(); da.Fill(dt); You need to add a new column to the data table named ItemSubtotal. The ItemSubtotal column must contains the named of the UnitPrice column multipled by the value of the Quantity column. Which code segment should you use? DataColumn col = new DataColumn("ItemSubTotal"); col.DataType - typeof(decimal); col.Expression = "UnitPrice * Quantity"; Dt.Column.Add(col); dt.Compute("UnitPrice * Quantity", ""ItemSubtotal"); DataColumn col = DataColumn("ItemSubtotal"); col.DataType - typeof(decimal); dt.Column.Add(col); dt.Compute("UnitPrice * Quantity", ""ItemSubtotal"); DataColumn col = new DataColumn("ItemSubtotal"); col.DataType - typeof(decimal); col.DefaultValue = "UnitPrice * Quantity"; dt.Colums.Add(col); Answer: A QUESTION 86: You are creating a Windows Forms application. The application loads a data table named dt from a database and modifies each value in the data table. You add the following code. (Line numbers are included for reference only.) 01 foreach (DataRow row in dt.Rows) { 02 foreach (DataColumn col in dt.Columns) { 03 04 Trace.WriterLine(str); 05 } 06 } You need to format the string named str to show the value of the column at the time the data is loaded and the current value in the column. Which code segment should you add at line 03? string str = String.Format("Column was {0} is now {1}", row[col], row[col, DataRowVersion.Current]); string str = String.Format("Column was {0} is now {1}", row[col, DataRowVersion.Default], row[col]); string str = String.Format("Column was {0} is now {1}", row[col], row[col, DataRowVersion.Proposed]); string str = String.Format("Column was {0} is now {1}", row[col, DataRowVersion.Original], row[col]); Answer: D QUESTION 87: You are creating a Windows Forms application that includes the database helper methods UpdateOrder and UpdateAccount. Each method wraps code that connect to a Microsoft SQL Server 2005 database, executes a Transact-SQL statment, and then disconnects from the database. You must ensure that changes to the database that result from the UpdateAccount method are committed only if the UpdateOrder method succeeds. You need to execute the UpdateAccount method and the UpdateOrder method. Which code segment should you use? using (TransactionScope ts = new TransactionScope()) { UpdateOrder(); UpdateAccount(); ts.Complete(); } using (TransactionScope ts1 = new TransactionScope()) { UpdateOrder(); using (TransactionScope ts2 = new TransactionSclope(TransactionScopeOption.RequiresNew)) { UpdateAccount(); ts2.Complete(); } ts1.Complete(); } using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) { UpdateOrders.(); ts.Compele(); } using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { UpdateAccount(); ts.Complete(); } using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequresNew)) { UpdateOrder(); } using (TransactionScope ts = new Answer: A QUESTION 88: You are customizing a Windows Form to use a BackgroundWorker component named bgwExecute. bgwExecute perform a database operation by an event handler named WorkHandler. You need to ensure that users can see the progress of the database operation by viewing a progress bar named pbProgress. You want the progress bar to appear when the database operation is 50 percent complete. Which code segment should you use? public void StartBackground() { bgwExecute.WorkerReportsProgress = true; bgwExecute.ProgressChanged += new ProgressChangedEventHandler(ProgressHandler); bgwExecute.Run WorkerAsync(); } void WorkHandler(object sender, DoWorkEventArgs e) { pbProgress.ReportProgress(50); } void ProgressHandler(object sender, ProgressChangedEventArgs e) { pbProgress.Value = e.ProgressPercentage; } public void StartBackground() { bgwExecute.WorkerReporterProgress = true; bgwExecute.ProgressChanged += new ProgressChangedEventHandler(ProgressHandler); ThreadStart t = new ThreadStart(WorkHandler); bgwExecute.RunWorkerAsync(t); } void WorkHandler() { bgwExecute.ReporterProgress(50); } void ProgressHandler(object sender, ProgressChangedEventArgs e) { bgProgress.Value = e.ProgressPercentage; } public void StartBackground() { bgwExecute.WorkerReporterProgress = true; bgwExecute.ProgressChanged += new ProgressChangedEventHandler(ProgressHandler); Thread t = new Thread(new ThreadStart(WorkHandler)); bgwExecute.RunWorkerAsync(t); } void WorkHandler() { bgwExecute.ReporterProgress(50); } void ProgressHandler(object sender, ProgressChangedEventArgs e) { bgProgress.Value = e.ProgressPercentage; } public void StartBackground() { bgwExecute.WorkerReportsProgress = true; bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.ProgressChanged += new ProgressChangedEventHandler(ProgressHandler); bgwExecute.RunWorkerAsync();} void WorkHandler(object sender, DoWorkEventArgs e) { bgwExecute.ReporterProgress(50);} void ProgressHandler(object sender, ProgressChangedEventArgs e) { pbProgress.Value =e.ProgressPercentage:} Answer: D QUESTION 89: You are customizing a Windows Form to asynchronously update a database in a method named WorkHandler. You need to ensure that the form displays a message box to the user that indicates the success of failure of the update. Which segment should you use? A. private void StartBackgroundProcess() { bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedHandler); bgwExecute.RunWorkerAsync(); } void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) { bool result = (bool) e.Result; MessageBox.Show("Update " + (result ? "was successfull" : "failed"));) } void WorkHandler(object sender, DoWorkEventArgs e) { // ... e.Result = true; } private void StartBackgroundProcess() { bgwExecute.ProgressChanged += new ProgressChangedEventHandler(CompletedHandler); ThreadStart tsBackground = new ThreadStart(WorkHandler); bgwExecute.RunEorkAsync(tsBackground); } void ProgressHandler(object sender, ProgressChangedEventArgs e) { bool result = (bool)e.UserState; MessageBox.Show("Update " + (result ? "was successful" : "failed")); } void WorkHandler() { // ... bgwExecute.ReportProgress(100, true); } private void StartBackgroundProcess() { bgwExecute.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedHandler); ThreadStart tsBackground = new ThreadStart(WorkHandler); bgwExecute.RunEorkAsync(tsBackground); } void CompletedHandlar(object sender, RunWorkerCompletedEventArgs e) { bool result = (bool)e.Result; MessageBox.Show("Update " + (result ? "was successful" : "failed")); } void WorkHandler() { // ... e.Result = true; } Private void StartBackgroundProcess() { bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedHandler); bgwExecute.RunWorkerAsync(); Answer: A QUESTION 90: You want to execute an event handler asynchronously from a Windows Form. You need to execute a method named WorkHandler by using an instance of the BackgroundWorker component named bgwExecute. Which two code segment should you use? (Each correct answer presents part of the solution. Choose two.) EventHandler work = new EventHandler(WorkHandler); ThreadStart work = new ThreadStart(WorkHandler); bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.RunWorkerAsync(); bgwExecute.RunWorkerAsync(Work); Answer: C, D QUESTION 91: You are creating a Windows Forms application. You want to execute a method named ProcessAmount in the background of the application. The method you want to execute requires that an integer value of 13 is passed. You need to pass an integer value of 13 to a starting background thread. Which two code segment should you use? (Each correct answer presents part of the soluiton. Choose two.) ThreadStart ts = new ThreadStart(ProcessAmount); Thread t = new Thread(ts, 13); ParameterizedThreadStart ts = new ParameterizedThreadStart(ProcessAmount); Thread t = new Thread(ts); t.Start(); t.Start(13); Answer: B, D QUESTION 92: You are creating a Windows Forms that includes printing functionality to print an image of the form. A helper function with the following signature creates a bitmap of the current form. private Bitmap CreateFormImageBitmap(Graphics graphic) You need to implement the PrintPage event handler to call the helper function and draw the image onto the print document. Which code segment should you use? Grafics g = e.Graphics;Bitmap formImageBitmap = VreateFormImageBitmap(g); e.graphics.DrawImage(formImageBitmap, e.MarginBounds); Grafics g = this.CreateGraphics(); BitmapformImageBitmap = CreatFormImageBitmap(g); g.DrawImage(formImageBitmap, g.ClipBound); g.Dispose(); Grafics g = this.CreateGraphics(); Bitmap formImageBitmap = CreatFormImageBitmap(e.Graphics); g.DrawImage(formImageBitmap, g.ClipBound); g.Dispose(); Grafics g = this.CreateGraphics(); Bitmap formImageBitmap = CreatFormImageBitmap(g); e.Graphics.DrawImage(formImageBitmap, e.MarginBounds); Answer: D QUESTION 93: You are creating a Windows Forms application. You create a System.Threading.Semaphore instance in the application by using the follwing code. Semaphore threadPool = new Semaphore(0, 3); // ...ThreadPool.Release(4); What does this code do? Sets the internal counter for the semaphore to 4. Sets the internal counter for the semaphore to 0. Throws a SemaphoreFullException. Throws a ThreadAbortException. Answer: C QUESTION 94: You are creating a Windows Form. You add a TableLayoutPanel control named pnlLayout to the form. You set the properties of pnlLayout so that is ... resize with the form. You need to create a three-column layout that has fixed left and right columns. The fixed columns must each remain 50 pixels wide when the form is resized. The middle column must fill the remainder of the form width when the form is resized. You add the three columns in the designer. Which code segment should you use to format the columns at run time? pnlLayout.ColumnStyles.Clear(); pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute,50F)); pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 100F)); onlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F)); pnlLayout.ColumnStyles[0].With = 50F; pnlLayout.ColumnStyles[0].SizeType = SizeType.Absolute;pnlLayout.ColumnStyles[2].Width = 50F; pnlLayout.ColumnStyles[2].SizeType = SizeType.Absolute; pnlLayout.ColumnStyles[0].With = 50F; pnlLayout.ColumnStyles[0].SizeType = SizeType.Absolute;pnlLayout.ColumnStyles[1].Width = 100F; pnlLayout.ColumnStyles[1].SizeType = SizeType.Absolute; pnlLayout.ColumnStyles[2].With = 50F; pnlLayout.ColumnStyles[2].SizeType = SizeType.Absolute; pnlLayout.ColumnStyles.Clear(); pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute,50F));pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent,100F));pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute,50F)); Answer: D QUESTION 95: You are creating a Windows Forms application. You implement the asynchronous design pattern by using a delegate named DataUpdateHandler. DataUpdateHandler executes a method named DataUpdater. You create an instance of the DataUpdateHandler that has the variable name Updater. DataUpdater uses a DataSet class as a parameter and returns an integer value that indicates the number of rows that have been updated. You need to use a method name DisplayResult to display the result when the database update is complete. Which code segment should you use? IAsyncResult result = Update .BeginInvoke(mData, null,null); //... int value = (int)result.AsyncState; DisplayResult(value); IAsyncResult result = Update .BeginInvoke(mData, null,null); //... int value = Updater.EndInvoke(result); DisplayResult(value); IAsyncResult result = Update .BeginInvoke(mData, null "DisplayResults"); //... Updater.EndInvoke(result); IAsyncResult result = Update .BeginInvoke(mData, null "DataUpdater"); //... Updater.EndInvoke(result); Answer: B QUESTION 96: You want to execute an event handler asynchronously from a Windows Form. You need to write code that uses the BackgroundWorker component named bgwExecute to execute the WorkHandler method. Which code segment should you use? EventHandler work = new EventHandler(WorkHandler); bgwExecute.RunWorkerAsync(Work); ThreadStart tsBackground = new ThreadStart(WorkHandler); bgwExecute.ReporterProgress(100, tsBackground); ThreadStart tsBackground = new ThreadStart(WorkHandler); bgwExecute.RunWorkerAsync(tsBackground); bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.RunWorkerAsync(); Answer: D QUESTION 97: You are cutomizing a Windows Form. The form includes a menu that has several ToolStripMenuItem controls. An event handler is configured to handle the Click event for all ToolStripMenuItem controls. The event handler has the following signature. private void menu_Click(object sender, EventArgs e) The form class includes a method that has the following signature. private void LogClick(string ctlName) You need to add code so that when a user clicks a ToolStripMenuItem control, the menu_Click method calls the LogClick method. The LogClick method must be called with the ctlName parameter set to the menu text in the ToolStripMenuItem control. Which code segment should you use? ToolStripMenuItem mnuItem = (ToolStripMenuItem)sender; LogClick(mnuItem.Text); LogClick(e.ToString()); LogClick(this.Text); ToolStripMenuItem mnuItem = (ToolStripMenuItem) this. GetContainerControl(); LogClick(mnuItem.Text); Answer: A QUESTION 98: You are creating a Windows Form that includes a TextBox control named txtDate. When a user right click within the text box, you want the application to display a MonthCalendar control. You need to implement a context menu that provides this functionality. What should you do? A. Add the following code to the form initialization. MonthCalender cal=new MonthCalender(); ContextMenuStrip mnuContext=new ContextMenuStrip(); ToolStripControlHost host = new ToolStripControlHost(mnuContext); txtDate.ContextMenuStrip=mnuContext Add the following code to the form initialization. ContextMenuStrip mnuContext=new ContextMenuStrip(); MonthCalender cal=new MonthCalender(); ToolStripControlHost host = new ToolStripControlHost(cal); mnuContext.Item.Add(host); txtData.ContextMenuStrip =mnuContext; Add the following code to the form initialization. ToolStripControl ctr=new ToolStripContainer(); MonthCalender cal=new MonthCalender(); ctr.ContentPanle.Controls.Add(cal); txtData.Controls.Add(ctr); Add a MouseClick event handler for the TextBox control that contains the following code. if (e.Button == MouseButton.Right) { txtData.Controls[0].Show(); } Add a MouseClick event handler for the TextBox control that contains the following code. if (e.Button == MouseButtons.Right) { ContextMenuStrip mnuContext=new ContextMenuStrip(); MonthCalender cal=new MonthCalender(); ToolStripControlHost host = new Answer: B QUESTION 99: You are creating a Windows Forms application. The application uses a SqlCommand object named cmd. The cmd object executes the following stored procedure. CREATE PROCEDURE GetPhoneList AS BEGIN SELECT CompnayName, Phone FROM Customers SELECT CompanyName, Phone FROM Suppliers END You need to add all returned rows to the ListBox control named lstPhones. Which code segment chould you use? A. SqlDataReader rdr = cmd.ExecuteReader(); do { while (rdr.Read()) { lstPhones.Items.Add(rdr.GetString(0) + "\t" +rdr.GetString(1)); } }while (rdr.NextResult()); SqlDataReader rdr = cmdExecuteReader(); while (rdr.Read()) { lstPhones.Items.Add(rdr.GetString(0) + "\t" +rdr.GetString(1)); } SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.NextResult()) { while (rdr.Read()) { lstPhones.Items.Add(rdr.GetString(0) + "\t" +rdr.GetString(1)); } } SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.NextResult()) { lstPhones.Items.Add(rdr.GetString(0) + "\t" +rdr.GetString(1)); } Answer: A QUESTION 100: A Windows Forms application reads the following XML file. Gambardella, Matthew XML Developer's Guide Ralis, Kim Midnight Rain The form initialization loads this file into an XmlDocument object named docBooks. You need to populate a ListBox control named lstBooks with the concatenated book ID and title of each book. Which code segment should you use? A. XmlNodeList elements=docBooks.GetElementsByTagName("Book"); foreach (XmlElement node in elements) { string s = node.GetAttribute("id") + "-"; s += node.SelectStingleNode("title").InnerText; 1stBook.Items.Add(s); } XmlNodeList elements=docBooks.GetElementsByTagName("Book"); foreach (XmlElement node in elements) { string s = node.SelectSingleNode("id") + "-"; s += node.GetAttribute("title"); 1stBook.Items.Add(s); } XmlNodeList elements=docBooks.GetElementsByTagName("Book"); foreach (XmlElement node in elements) { string s = node.GetAttribute("id") + "-"; s += node.SelectSingleNode("title");.Value 1stBook.Items.Add(s); } XmlNodeList elements=docBooks.GetElementsByTagName("Book"); foreach (XmlElement node in elements) { 1stBook.Items.Add(node.InnerXml); } Answer: A QUESTION 101: A Windows Forms application contains the following code segment. string SQL = @"SELECT EmployeeID, LastName, FirstName, FROM Emloyees"; SqlDataAdapter da = new SqlDataAdapter(SQL, connStr); DataTable dt = new DataTable(); da.MissingSchemaAction = MissingSchemaAction.AddWithKey; SqlCommandBuilder bld = new SqlCommandBuilder(da); da.Fill(dt); The application allows the user to add rows to the data table. The application will propagate these additions to the database. If the addition of any row fails, the other rows must still be added. The code must log how many new rows to be added. You need to propagate the additions to the database and log a failed count. Which code segment should you use? da.ContinuUpdateError = true; da.Update(dt); DataTable dtError = dt.GetChanges(DataRowState.Unchanged); Trace.WriteLine(dtErrors.Rows.Count.ToString() + "rows not added."); da.ContinueUpdateOnError=false; da.Update(dt); DataTable dtError = dt.GetChanges(DataRowState.Unchanged); Trace.WriteLine(dtErrors.Rows.Count.ToString() + "rows not added."); da.ContinuUpdateError = true; da.Update(dt); DataRow[] rows = dt.GetErrors(); Trace.WriteLine(rows.Lenght.ToString() + "row not added."); da.ContinuUpdateOnError = false; da.Update(dt); DataRow[] rows = dt.GetErrors(); Trace.WriteLine(rows.Lenght.ToString() + "row not added."); Answer: C QUESTION 102: You are customizing a Windows Form to asynchronously update a database. You need to ensure that the form display a message box to the user that indicates the success or failure of the update. Which three code segment should you use? (Each correct answer presents part of the solution. Choose three.) A. private void StartBackGroundProcess() { bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedHandler); bgwExecute.RunWorkerAsync(); } private void StartBackgroundProcess() { bgwExecute.ProcessChanged += newProgressChangedEventHandler(CompeletedHandler); ThreadStart tsBackground = new ThreadStart(WorkHandler); bgwExecute.RunEorkAsync(tsBackground); } private void StartBackgroundProcess() { bgwExecute.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedHandler); ThreadStart tsBackground = new ThreadStart(WorkHandler); bgwExecute.RunEorkAsync(tsBackground); } void WorkHandler(object sender, DoWorkEventArgs e) { // ... e.Result=true; } void WorkHandler(object sender, DoWorkEventsArgs e) { // ... bgwExecute.ReportProgress(100, true); } void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) { bool result = (bool)e.Result; MessageBox.Show("Update " + (result ? "was successful" : "failed")); } void ProgressHandler(object sender, ProgressChangeEventArgs e) { bool result = (bool)e.UserState; MessageBox.Show("Update " + (result ? "was successful" : "failed")); } Answer: A, D, F QUESTION 103: You are customizing a Windows Form to update a database asynchronously by using an instance of a BackgroundWorker component named bgwExecute. You start the component by using the following code. private void StartBackgroundProcess() { bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler); bgwExecute.DoWorkerCompleted += new Do WorkerCompletedEventHandler(CompletedHandler); bgwExecute.ProgressChanged += new ProgressChangedEventHandler(ProgressHandler); bgwExecute.RunWorkerAsync(); } If the UpdateDB method that is called by the BackgroundWorker component returns the value False, you need to display a message box to the user that indicates that the update failed. Which code segment should you use? void WorkHandler(object sender, DoWorkEventArgs e) { if (!UpdateDB()) MessageBox.Show("Update failed"); } void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) { if (!UpdateDB()) MessageBox.Show("Update failed"); } void WorkHandler(object sender, DoWorkEventArgs e) { e.Result = UpdateDB(); } void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) { if (!(bool) e.Result MessageBox.Show("Update failed"); } D. void WorkHandler(object sender, DoWorkEventArgs e) { e.Result = UpdateDB(); } void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) { Answer: C QUESTION 104: You create an application that provide accessibility features. Your standard forms display a background image. When the user selects Use High Constrast in the Accessibility Options in Control Panel, you want this image to be removed. You need to add an event to handle this accessibility setting change. Which event should you use? this.StyleChanged SystemEvents.UserPreferenceChanged this.ChangeUICues SystemEvents.DisplaySettingsChanged Answer: B QUESTION 105: You are creating a Windows Forms application. You add an ErrorProvider component named erpErrors and a DateTimePicker control named dtpStartDate to the application. The application also contains other controls. You need to configure the application to display an error notification icon next to dtpStartDate when the user enters a date that is greater than today's date. Which two action should you perform? (Each correct answer presents part of the solution. Choose two.) For the Validating event of dtpStartDate, create an event handler named VerifyStartDate. For the Validated event of dtpStartDate, create an event handler named VerifyStartDate. In the Properties Window for dtpStartDate, set the value of Error on erpErrors to Date out of range . In VerifyStartDate, call erpErrors.SetError(dtpStartDate, "Date out of range") if the value of dtpStartDate value is greater than today's date. In VerifyStartDate, call erpErrors.SetError(dtpStartDate, null) if the dtpStartDate.Value is greater than today's date. Answer: A, E QUESTION 106: You are creating a Windows Form that includes a TextBox control named txtDate. When a user right-clicks within the text box, you want the application to display a MonthCalendar control. You need to implement a context menu that provides this functionality. What should you do? Add the following code to the form initialization. MonthCalender^cal = gcnew MonthCalender(); ContextMenuStrip^mnuContext = gcnew ContextMenuStrip(); ToolStripControlHost^host = gcnew ToolStipControlHost(mnuContext); txtData->ContextMenuStrip = mnuContext; Add the following code to the form initialization.ContextMenuStrip ^mnuContext = gcnew ContextMenuStrip(); MonthCalender^cal = gcnew MonthCalender(); ToolStripControlHost^host = gcnew ToolStipControlHost(cal); mnuContext->Items->Add = (host); txtData->ContextMenuStrip = mnuContext; Add the following code to the form initialization.ToolStripContainer ^ctr = gcnew ToolStripContainer(); MonthCalender^cal = gcnew MonthCalender(); ctr->Controls->Add(ctr); Add a MouseClick event handler for the TextBox control that contains the following code.if (e->Button ==MouseButtons::Right) {txtData->Controls[0]->Show(); } Add a MouseClick event handler for the TextBox control that contains the following code.if (e->Button == MouseButtons::Right) { ContextMenuStrip ^mnuContext = gcnew ContextMenuStrip(); MonthCalender^cal = gcnew MonthCalender(); ToolStripControlHost^host = gcnew ToolStipControlHost(cal); mnuContext->Items->Add = (host); txtData->ContextMenuStrip = mnuContext; } Answer: B QUESTION 107: You are creating a Windows Form. You add a TableLayoutPanel control named pnlLayout to the form. You set the properties of pnlLayout so that it will resize with the form. You need to create a three-column layout that has fixed left and right columns. The fixed columns must each remain 50 pixels wide when the form is resized. The middle column must fill the remainder of the form width when the form is resized. You add the three columns in the designer. Which code segment should you use to format the columns at run time? A. pnlLayout->ColumnStyles->Clear(); pnlLayout->ColumnStyles->Add(gcnew ColumnStyle(SizeType::Absolute, 50)); pnlLayout->ColumnStyles->Add(gcnew ColumnStyle(SizeType::AutoSize, 100)); pnlLayout->ColumnStyles->Add(gcnew ColumnStyle(SizeType::Absolute, 50)); B. pnlLayout->ColumnStyles[0]->Width = 50; pnlLayout->ColumnStyles[0]->SizeType = SizeType::Absolute; pnlLayout->ColumnStyles[2]->Width = 50; pnlLayout->ColumnStyles[2]->SizeType = SizeType::Absolute; C. pnlLayout->ColumnStyles[0]->Width = 50; pnlLayout->ColumnStyles[0]->SizeType = SizeType::Absolute; pnlLayout->ColumnStyles[1]->Width = 100; pnlLayout->ColumnStyles[1]->SizeType = SizeType::Absolute; pnlLayout->ColumnStyles[2]->Width = 50; pnlLayout->ColumnStyles[2]->SizeType = SizeType::Absolute; D. pnlLayout->ColumnStyles->Clear(); pnlLayout->ColumnStyles->Add(gcnew ColumnStyle(SizeType::Absolute, 50)); pnlLayout->ColumnStyles->Add(gcnew ColumnStyle(SizeType::Percent, 100)); pnlLayout->ColumnStyles->Add(gcnew ColumnStyle(SizeType::Absolute, 50)); Answer: D QUESTION 108: You are customizing a Windows Form. The form includes a menu that has several ToolStripMenuItem controls. An event handler is configured to handle the Click event for all ToolStripMenuItem controls. The event handler has the following signature. private: void mnu_Click(Object ^sender, EventArgs ^e) The form class includes a method that has the following signature. private: void LogClick(String ^ctlName) You need to add code so that when a user clicks a ToolStripMenuItem control, the mnu_Click method calls the LogClick method. The LogClick method must be called with the ctlName parameter set to the menu text in the ToolStripMenuItem control. Which code segment should you use? ToolStripMenuItem^mnbItem = (ToolStripMenuItem^)sender; LogClick(mnuItem->Text); LogClick(e->ToString()); LogClick(this->Text); ToolStripMenuItem^mnbItem = (ToolStripMenuItem^) this->GetContainerControl(); LogClick(mnuItem->Text); Answer: A QUESTION 109: You are localizing a Windows Forms application. You put all error message strings into a resource file named ErrorMessages.resx. When the resource file is compiled, a strongly typed resource class is generated. You need to retrieve an error message named CatastrophicErr from the exception-handling code. Which code segment should you use? ResourceManager ^LocRM = gcnew ResourceManager("TestApp.ErrorMessages", Sysytem::Reflection::Assembly::GetExecutingAssembly()); String ^s = LocRM->GetString("CatastrophicErr"); String s = ConfigurationSettings::ApppSettings["ErrorMessage_CatastrophicErr"]->ToString(); StringInfo^si = gcnew StringInfo("ErrorMessage_CatastrophicErr"); String ^s = si->String; Assembly ^a = Assembly::GetExecutingAssembly(); Stream ^stream =a->GetMainifestResourcesStream("ErrorMessage_CatastrophicErr"); StreamReader ^sr = gcnew StreamReader(stream); String ^s = sr->ReadToEnd(); Answer: A QUESTION 110: You create an application that provides accessibility features. Your standard forms display a background image. When the user selects Use High Contrast in the Accessibility Options in Control Panel, you want this image to be removed. You need to add an event to handle this accessibility setting change. Which event should you use? this->StyleChanged SystemEvents::UserPreferenceChanged this->ChangeUICues SystemEvents::DisplaySettingsChanged Answer: B QUESTION 111: You are creating a Windows Form that includes printing functionality to print an image of the form. A helper function with the following signature creates a bitmap of the current form. private: Bitmap ^CreateFormImageBitmap(Graphics ^graphic) You need to implement the PrintPage event handler to call the helper function and draw the image onto the print document. Which code segment should you use? A. Graphics ^g = e->Graphics; Bitmap ^formImageBitmap = CreateFormImageBitmap(g); e->Graphics ->DrawImage(formImageBitmap, e->MargineBound); B. Graphics ^g = this->CreatGraphics(); Bitmap ^formImageBitmap = CreateFormImageBitmap(g); g->DrawImage(formImageBitmap, g->ClipBounds); C. Graphics ^g = this->CreatGraphics(); Bitmap ^formImageBitmap = CreateFormImageBitmap(e->Graphics); g->DrawImage(formImageBitmap, g->ClipBounds); D. Graphics ^g = this->CreatGraphics(); Bitmap ^formImageBitmap = CreateFormImageBitmap(g); e->Graphics->DrawImage(formImageBitmap, e->MargineBound); Answer: D QUESTION 112: Your law firm uses a custom application to create and print legal documents. Currently, users can print any portion of a document that they want from the application by using the options in the Print dialog box. This Print dialog box was implemented by using the PrintDialog component. New security and auditing rules state that the application must implement a business rule that requires users to print documents in their entirety. Printing only portions of a document is prohibited. You need to modify the PrintDialog component named printDlg to enforce the business rule when a user prints. You must implement this rule with the minimum amount of impact to users. What should you do? A. Set the PrintDialog component to printDlg->PrinterSettings->PrintRange = PrintRange::AllPages. Call the printDlg->Reset method when the Print dialog box is closed. Configure the following settings for the PrintDialog component.printDlg->AllowSomePages = false; printDlg->AllowSelection = false; printDlg->AllowCurrentPage = false; Create a warning message that displays if the user selects the Pages option in the Print dialog box to try to print a subset of a document. Use the following settings to set the full document to print.printDlg->PrinterSettings->FromPage = printDlg->PrintSettings->MinimumPage; printDlg->PrintSettings->ToPage; = printDlg->PrintSettings->MaximumPage; Answer: C QUESTION 113: A Windows Forms application contains the following code segment. String ^SQL = "SELECT EmployeeID, LastName, FirstName FROM Emloyees"; SqlDataAdapter ^da = gcnew SqlDataAdapter(SQL, connStr); DataTable ^dt = gcnew DataTable(); da->MissingSchemaAction = MissingSchemaAction::AddWithKey; SqlCommandBuilder ^bld = gcnew SqlCommandBuilder(da); da->Fill(dt); The application allows the user to add rows to the data table. The application will propagate these additions to the database. If the addition of any row fails, the other rows must still be added. The code must log how many new rows failed to be added. You need to propagate the additions to the database and log a failed count. Which code segment should you use? da->ContinueUpdateOnError = true; da->Update(dt); DataTable ^dtError = dt->GetChanges(DataRowState::Unchanged); Trace::WriteLine(dtError->Rows->Count.ToString() + "row not added."); da->ContinueUpdateOnError = false; da->Update(dt); DataTable ^dtError = dt->GetChanges(DataRowState::Unchanged); Trace::WriteLine(dtError->Rows->Count.ToString() + "row not added."); da->ContinueUpdateOnError = true; da->Update(dt); array ^rows = dt->GetErrors(); Trace::WriteLine(rows->Lenght.ToString() + "row not added."); da->ContinueUpdateOnError = false; da->Update(dt); array ^rows = dt->GetErrors(); Trace::WriteLine(rows->Lenght.ToString() + "row not added."); Answer: C QUESTION 114: You are creating a Windows Forms application. The application uses a SqlCommand object named cmd. The cmd object executes the following stored procedure. CREATE PROCEDURE GetPhoneList AS BEGIN SELECT CompanyName, Phone FROM Customers SELECT CompanyName, Phone FROM Suppliers END You need to add all returned rows to the ListBox control named lstPhones. Which code segment should you use? A. SqlDataReader ^rdr = cmd->ExecuteReader(); do { while (rdr->Read()) { lstPhones->Items->Add(rdr->GetString(0) + "\t" + rdr->GetString(1)); }}while (rdr->NextResult()); B. SqlDataReader ^rdr = cmd->ExecuteReader(); while (rdr->Read()) { lstPhones->Items->Add(rdr->GetString(0) + "\t" + rdr->GetString(1)); } C. SqlDataReader ^rdr = cmd->ExecuteReader(); while (rdr->NextResult()) { while (rdr->Read()) { lstPhones->Items->Add(rdr->GetString(0) + "\t" +rdr.GetString(1)); }} D. SqlDataReader ^rdr = cmd->ExecuteReader(); while (rdr->NextResult()) { lstPhones->Items->Add(rdr->GetString(0) + "\t" + rdr->GetString(1)); } Answer: A QUESTION 115: A Windows Forms application reads the following XML file. Gambardella, Matthew XML Developer's Guide Ralls, Kim Midnight Rain The form initialization loads this file into an XmlDocument object named docBooks. You need to populate a ListBox control named lstBooks with the concatenated book ID and title of each book. Which code segment should you use? A. XmlNodeList ^elements=docBooks->GetElementsByTagName("Book"); for each (XmlElement ^node in elements) { string ^s = node->GetAttribute("id") + "-"; s += node->SelectStingleNode("title")->InnerText; 1stBook->Items->Add(s); } B. XmlNodeList ^elements=docBooks->GetElementsByTagName("Book"); for each (XmlElement ^node in elements) { String ^s = node->SelectSingleNode("id") + + "-"; s += node->GetAttribute("title"); 1stBook->Items->Add(s); } C. XmlNodeList elements=docBooks->GetElementsByTagName("Book"); for each (XmlElement ^node in elements) { string ^s = node->GetAttribute("id") + "-"; s += node->SelectStingleNode("title")->Value; 1stBook->Items->Add(s); } D. XmlNodeList elements=docBooks->GetElementsByTagName("Book"); for each (XmlElement ^node in elements) {1stBook->Items->Add(node->InnerXml); } Answer: A QUESTION 116: You are creating a Windows Forms application. You implement the asynchronous design pattern by using a delegate named DataUpdateHandler. DataUpdateHandler executes a method named DataUpdater. You create an instance of the DataUpdateHandler that has the variable name Updater. DataUpdater uses a DataSet class as a parameter and returns an integer value that indicates the number of rows that have been updated. You need to use a method named DisplayResults to display the results when the database update is complete. Which code segment should you use? IAsyncResult^ result = Updater->BeginInvoke(mData, nullptr,nullptr); //...other work or synchronizationint value = (int)result->AsyncState; DisplayResults(value); IAsyncResult^ result = Updater->BeginInvoke(mData, nullptr,nullptr); //...other work or synchronizationint value = Updater->EndInvoke(result); DisplayResults(value); IAsyncResult^ result = Update->.BeginInvoke(mData, nullptr, "DisplayResults"); //...other work or synchronizationUpdater->EndInvoke(result); IAsyncResult^ result = Update->BeginInvoke(mData, nullptr, "DataUpdater"); //...other work or synchronizationUpdater->EndInvoke(result); Answer: B QUESTION 117: You are customizing a Windows Form to asynchronously update a database. You need to ensure that the form displays a message box to the user that indicates the success or failure of the update. Which three code segments should you use? (Each correct answer presents part of the solution. Choose three.) private: void StartBackgroundWorkerProcess() { bgwExecute->DoWork += gcnew Do WorkEventHandler(this, &Form1::WorkHandler); bgwExecute->RunWorkerCompleted += gcnew Run WorkerCompletedEventHandler(this, &Form1::CompletedHandler); bgwExecute->RunWorkerAsync(); } private: void StartBackgroundWorkerProcess() { bgwExecute->ProgressChanged += gcnew progressChangedEventHandler(this, &Form1::CompletedHandler); ThreadStart^ tsBackground = gcnew ThreadStart(this, &Form1::CompletedHandler); bgwExecute->RunWorkerAsync(tsBackground); } private: void StartBackgroundWorkerProcess() { bgwExecute->RunWorkerCompleted += gcnew Run WorkerCompletedEventHandler(this, &Form1::CompletedHandler); ThreadStart^ tsBackground = gcnew ThreadStart(this, &Form1::WorkdHandler); bgwExecute->RunWorkerAsync(tsBackground); } D. void WorkHandler(Object^ sender, Do workEventArgs^e) {//...e->Result = true; } void WorkHandler(Object^ sender, DoWorkEventArgs^ e) { // ... bgwExecute->ReportProgress(100, tru); } void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Result; MessageBox::Show("Update " + (result ? "was successful" : "failed")); } void CompletedHandler(Object^ sender, ProgressChangedEventArgs^ e){ bool result = (bool)e->UserState; MessageBox::Show("Update " + (result ? "was successful" : "failed")); } Answer: A,D,F QUESTION 118: You want to execute an event handler asynchronously from a Windows Form. You need to write code that uses the BackgroundWorker component named bgwExecute to execute the WorkHandler method. Which code segment should you use? EventHandler^ work = gcnew EventHandler(this, &Form1::WorkHandler); bgwExecute->RunWorkerAsync(Work); ThreadStart^ tsBackground = gcnew ThreadStart(this, &Form1::WorkHandler); bgwExecute->ReportProgress(100, tsBackground); ThreadStart^ tsBackground = new ThreadStart(this, &Form1::WorkHandler); bgwExecute->RunWorkerAsync(tsBackground); bgwExecute->DoWork += new DoWorkHandler(this, &Form1::WorkHandler); bgwExecute->RunWorkerAsync(); Answer: D QUESTION 119: You are customizing a Windows Form to update a database asynchronously by using an instance of a BackgroundWorker component named bgwExecute. You start the component by using the following code. private: void StartBackgroundProcess(){ bgwExecute->DoWork += gcnew DoWorkEventHandler(this, &Form1::WorkHandler); bgwExecute->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler(this, &Form1::CompletedHandler); bgwExecute->WorkerReportProgress= true; bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this, &Form1::ProgressChanged); bgwExecute.RunWorkerAsync(); } If the UpdateDB method that is called by the BackgroundWorker component returns the value False, you need to display a message box to the user that indicates that the update failed. Which code segment should you use? void WorkHandler(Object^ sender, DoWorkEventArgs^ e) { if (!UpdateDB()) MessageBox::Show("Update failed"); } void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ if (! UpdateDB()) MessageBox::Show("Update failed"); } void WorkHandler(object^ sender, DoWorkEventArgs^ e) {e->Result = UpdateDB(); } void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e) { if (!(bool) e->Result) MessageBox::Show("Update failed"); } void WorkHandler(Object^ sender, DoWorkEventArgs^ e) { e->Result = UpdateDB(); } void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e) { if (!(bool) e->Result) bgwExecute->ReportProgress(0); } void ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e) { if (e->ProgressPercentage==0) MessageBox::Show("Update failed"); } Answer: C QUESTION 120: You are creating a Windows Forms application. You create a System.Threading.Semaphore instance in the application by using the following code. Semaphore^ threadPool = gcnew Semaphore(0, 3); //... threadPool ->Release(4); What does this code do? Sets the internal counter for the semaphore to 4. Sets the internal counter for the semaphore to 0. Throws a SemaphoreFullException. Throws a ThreadAbortException. Answer: C QUESTION 121: You are customizing a Windows Form to use a BackgroundWorker component named bgwExecute. bgwExecute performs a database operation in an event handler named WorkHandler. You need to ensure that users can see the progress of the database operation by viewing a progress bar named pbProgress. You want the progress bar to appear when the database operation is 50 percent complete. Which code segment should you use? public: void StartBackground() {bgwExecute-> WorkerReportProgress = true; bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this, &SolutionA::ProgressChanged); bgwExecute->RunWorkerAsync(); } void WorkHandler(Object^ sender, DoWorkEventArgs^ e){ bgwExecute->ReporterProgress(50); } void ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e){ pbprogress->Value = e->ProgressPercentage; } public: void StartBackground() {bgwExecute-> WorkerReportProgress = true; bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this, &SolutionB::ProgressChanged); ThreadStart^ t = gcnew ThreadStart(this, &SolutionB::WorkHandler); bgwExecute->RunWorkerAsync(t); } void WorkHandler() {bgwExecute->ReporterProgress(50); } void ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e) {pbProgress->Value = e->ProgressPercentage; } public: void StartBackground() {bgwExecute-> WorkerReportProgress = true; bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this, &SolutionC::ProgressChanged); ThreadStart^ t = gcnew Thread(gcnew ThreadStart(this, &SolutionC::WorkHandler) ); bgwExecute->RunWorkerAsync(t); } void WorkHandler() {bgwExecute->ReporterProgress(50); } void ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e) { pbProgress->Value = e->ProgressPercentage; } public: void StartBackground() {bgwExecute-> WorkerReportProgress = true; bgwExecute->DoWork += gcnew DoWorkEventHandler(this, &SolutionD::WorkHandler); bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this, &SolutionD::ProgressHandler); bgwExecute->RunWorkerAsync(); } void WorkHandler(Object^ sender, DoWorkEventArgs^ e) { bgwExecute->ReporterProgress(50); } void ProgressHandler(Object^ sender, ProgressChangedEventArgs^ e) { pbProgress->Value = e->ProgressPercentage; } Answer: D QUESTION 122: You want to execute an event handler asynchronously from a Windows Form. You need to execute a method named WorkHandler by using an instance of the BackgroundWorker component named bgwExecute. Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.) EventHandler^ work = gcnew EventHandler(this, &Form1::WorkHandler); ThreadStart^ work = gcnew ThreadStart(this, &Form1::WorkHandler); bgwExecute->DoWork += gcnew DoWorkEventHandler(this, &Form1::WorkHandler); bgwExecute->RunWorkerAsync(); bgwExecute->RunWorkerAsync(work); Answer: C,D QUESTION 123: You are creating a Windows Forms application. You want to execute a method named ProcessAmount in the background of the application. The method you want to execute requires that an integer value of 13 is passed. You need to pass an integer value of 13 to a starting background thread. Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.) ThreadStart^ ts = gcnew ThreadStart(this, &Form1::ProcessAmount); Thread^ t = new Thread(ts, 13); ParameterizedThreadStart^ ts = gcnew ParameterizedThreadStart(this, &Form1::ProcessAmount); Thread^ t = gcnew Thread(ts); t->Start(); t->Start(13); Answer: B,D QUESTION 124: You are customizing a Windows Form to update asynchronously a database in a method named WorkHandler. You need to ensure that the form displays a message box to the user that indicates the success or failure of the update. Which code segment should you use? private: Void StartBackgroundProcess() { bgwExecute->DoWork += gcnew Do WorkEventHandler(this, &Form1::WorkHandler); bgwExecute->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler(this, &Form1::CompletedHandler); bgwExecute->RunWorkerAsync(); } Void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Resul; MessageBox::Show("Update " + (result ? "was successful" : "failed")); } void WorkHandler(object^ sender, Do WorkEventArg^ e) {//...e->Result = true; } private: Void StartBackgroundProcess() { bgwExecute->ProgressChanged += gcnew ProgressChangedEventHandler(this, &Form1::ProgressHandler); ThreadStart^ tsBackground = gcnew ThreadStart(this, &Form1::WorkHandler); bgwExecute->RunWorkerAsync(tsBackgroud); } Void ProgressHandler(Object^ sender, ProgressChangedEventArgs^ e) { bool result = (bool)e->UserState; MessageBox::Show("Update " + (result ? "was successful" : "failed")); } void WorkHandler() {//...bgwExecute->ReportProgress(100,true); } private: Void StartBackgroundProcess(){ bgwExecute->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler(this, &SolutionC::CompletedHandler); ThreadStart^ tsBackground = gcnew ThreadStart(this, &SolutionC::WorkHandler); bgwExecute->RunWorkerAsync(tsBackgroud); } Void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Resul; MessageBox::Show("Update " + (result ? "was successful" : "failed")); } void WorkHandler() {//...bgwExecute->ReportProgress(100, true); } private: Void StartBackgroundProcess() { bgwExecute->DoWork += gcnew Do WorkEventHandler(this, &SolutionD::WorkHandler); bgwExecute->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler(this, &Form1::CompletedHandler); bgwExecute->RunWorkerAsync(); } Void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ bool result = (bool)e->Resul; MessageBox::Show("Update " + (result ? "was successful" : "failed")); } Void WorkHandler(Object^ sender, DoWorkEventArgs^ e) {//... bgwExecute->ReportProgress(100, true); } Answer: A QUESTION 125: You are creating a Windows Forms application. The application loads a data table named dt from a database and modifies each value in the data table. You add the following code. (Line numbers are included for reference only.) 01 for each (DataRow ^row in dt->Rows) { 02 for each (DataColumn ^col in dt->Columns) { 03 04 Trace::WriteLine(str); 05 } 06 } You need to format the string named str to show the value of the column at the time the data is loaded and the current value in the column. Which code segment should you add at line 03? String ^str = String::Format("Column was {0} is now {1}", row[col], row[col, DataRowVersion::Current]); String ^str = String::Format("Column was {0} is now {1}", row[col, DataRowVersion::Default,row[col]); String ^str = String::Format("Column was {0} is now {1}", row[col], row[col, DataRowVersion::Proposed]); String ^str = String::Format("Column was {0} is now {1}", row[col, DataRowVersion::Original], row[col]); Answer: D QUESTION 126: A Windows Forms application contains the following code segment. String ^SQL = "SELECT OrderID, ProductID, UnitPrice, Quantity FROM [Order Details]"; SqlDataAdapter ^da = qcnew SqlDataAdapter(SQL, connStr); DataTable ^dt = gcnew DataTable(); da->Fill(dt); You need to add a new column to the data table named ItemSubtotal. The ItemSubtotal column must contain the value of the UnitPrice column multiplied by the value of the Quantity column. Which code segment should you use? DataColumn ^col = gcnew DataColumn("ItemSubtotal"); col->DataType = System::Decimal::typeid; col->Expression = "UnitPrice * Quantity"; dt->Column->add(col); dt->Compute("UnitPrice * Quantity","ItemSubtotal"); DataColumn ^col = gcnew DataColumn("ItemSubtotal"); col->DataType = System::Decimal::typeid; dt->Column->add(col); dt->Compute("UnitPrice * Quantity","ItemSubtotal"); DataColumn ^col = gcnew DataColumn("ItemSubtotal"); col->DataType = System::Decimal::typeid; col->DefaultValue = "UnitPrice * Quantity"; dt->Column->add(col); Answer: A QUESTION 127: You are creating a Windows Forms application that includes the database helper methods UpdateOrder and UpdateAccount. Each method wraps code that connects to a Microsoft SQL Server 2005 database, executes a Transact-SQL statement, and then disconnects from the database. You must ensure that changes to the database that result from the UpdateAccount method are committed only if the UpdateOrder method succeeds. You need to execute the UpdateAccount method and the UpdateOrder method. Which code segment should you use? TransactionScope ^ts = gcnew TransactionScope(); try {UpdateOrder(); UpdateAccount(); ts->Complete(); } finally ( delete ts; } TransactionScope ^ts1 = gcnew TransactionScope(); try {UpdateOrder(); TransactionScope ^ts2 = gcnew TransactionScope(TransactionScopeOption::RequiresNew); try { UpdateAccount(); ts2->Complete(); } finally ( delete ts2; ts1->Complete(); }finally ( delete ts1; } TransactionScope ^ts = gcnew TransactionScope(TransactionScopeOption::RequiresNew); try { UpdateOrder(); ts->Complete(); } finally ( delete ts; } ts = gcnew TransactionScope(TransactionScopeOption::Requires); ts->Complete(); } finally ( delete ts; } D. TransactionScope ^ts = gcnew TransactionScope(TransactionScopeOption::RequiresNew); try { UpdateOrder(); } finally ( delete ts; } TransactionScope ^ts = gcnew TransactionScope(TransactionScopeOption::Requires); try { UpdateAccount(); ts->Complete(); } finally ( delete ts; } Answer: A QUESTION 128: You are creating a Windows Forms application. Initialization code loads a DataSet object named ds that includes a table named Users. The Users table includes a column named IsManager. You need to bind the IsManager column to the Checked property of a check box named chkIsManager. Which code segment should you use? chkIsManager->DataBindings->Add("Checked",ds, "User.IsManager"); chkIsManager->DataBindings->Add("Checked",ds, "IsManager"); chkIsManager->Test = "{User.IsManager}"; chkIsManager->AutoCheck = true; D. this->dataBindings->Add("chkIsManager.Checked",ds, "User.IsManager"); Answer: A QUESTION 129: You are customizing a Windows Form. When the user clicks any button, you want the application to log information about the users actions by calling a method with the following signature. public: System::Void ctl_Click(Object ^sender, EventArgs ^e) You want the form to invoke this method when any Button control is clicked and only when a Button control is clicked. You need to modify the form to invoke this method without interfering with the existing operations of the application. What should you do? A. Add the following code to the form initialization.for each (Control ^ctl in this->Controls) { if (dynamic_cast< Button ^ >(ctl) != nullptr){ ctl->Click += gcnew EventHandler(this, &Form1::ctl_Click); }} Add the following code to the form initialization.this->Click += gcnew EventHandler(this, &Form1::ctl_Click); Use the Properties dialog box to set the Click event for each Button control on the form to the ctl_Click method. Use the Properties dialog box to set the Click event of the form to the ctl_Click method. Answer: A QUESTION 130: You are creating a Windows Forms application. You add an ErrorProvider component named erpErrors and a DateTimePicker control named dtpStartDate to the application. The application also contains other controls. You need to configure the application to display an error notification icon next to dtpStartDate when the user enters a date that is greater than today's date. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.) For the Validating event of dtpStartDate, create an event handler named VerifyStartDate. For the Validated event of dtpStartDate, create an event handler named VerifyStartDate. In the Properties Window for dtpStartDate, set the value of Error on erpErrors to Date out of range. In VerifyStartDate, call erpErrors->SetError(dtpStartDate, "Date out of range") if the value of dtpStartDate->Value is greater than today's date. In VerifyStartDate, call erpErrors->SetError(dtpStartDate, "") if the value of dtpStartDate->Value is greater than today's date. Answer: A,E QUESTION 131: You are creating a custom control that displays an image in the background. You notice that when the control is resized, the background image flickers while the control is repeatedly repainted. You need to eliminate the background image flicker. Which three code segments should you use? (Each correct answer presents part of the solution. Choose three.) this->SetStyle(ControlStyles::OptimizedDoubleBuffer, true); this->SetStyle(ControlStyles::AllPaintingInWmPaint, true); this->SetStyle(ControlStyles::UserPaint, true); this->SetStyle(ControlStyles::ResizeRedraw, true); this->SetStyle(ControlStyles::Opaque, true); Answer: A,C,D QUESTION 132: You are creating a custom Windows Forms control. On the background of the control, an ellipse completely filled with a colored gradient is drawn. The bounds for the ellipse are equal to the bounds for the control. The control must correctly repaint itself in all situations. You need to include the drawing of the ellipse in the OnPaint event handler for the custom control. Which code segment should you use? Brush ^linearGradientBrush = gcnew LinearGradientBrush(e->ClipRectangle, startGradient, endGradient, 45); e->Graphics->FillEllipse(linearGradientBrush, e->ClipRectangle); Brush ^linearGradientBrush = gcnew LinearGradientBrush( Point(this->Left, this->Top), Point(this->Right, this->Bottom), startGradient, endGradient); e->Graphics->FillEllipse(linearGradientBrush, e->ClipRectangle); Brush ^linearGradientBrush = gcnew LinearGradientBrush( Rectangle(this->Left, this->Top, this->Width, this->Hight), startGradient, endGradient, 45, true); e->Graphics->FillEllipse(linearGradientBrush, this->Left, this->Top, this->Width, this->Height); Brush ^linearGradientBrush = gcnew LinearGradientBrush(this->ClientRectangle, startGradient, endGradient, 45); e->Graphics->FillEllipse(linearGradientBrush, this->ClientRectangle); Answer: D QUESTION 133: You are creating a Windows Forms application that prints reports. The application uses the PrintDocument control to print the report and the PrintPreviewDialog control to preview reports as shown in the following code segment. streamToPoint = gcnew StreanReader("..\\..\\FileToPrint.txt"); try { PrintDocument ^pd = gcnew PrintDocument(); pd->PrintPage += gcnew PrintPageEventHandler(this, &Form1::pd_PrintPage); PrintPreviewDialog ^ppd = gcnew PrintPreviewDialog(); ppd->Document = pd; ppd->ShowDialog(); } finally { streamToPrint->Close(); } When a report is printed by using the Print method on the PrintDocument class, the output is correct. When the report is previewed by using the Print Preview dialog box, the output is correct. However, when the report is printed by using the Print button in the Print Preview dialog box, a single blank page is produced. You need to ensure that the output is correct when the Print button in the Print Preview dialog box is used. What should you do? In the event handler for the ppd_Click event, set the position of the streamToPrint->BaseStream property to 0. In the event handler for the ppd_PrintPreviewControl_Click event, set the position of the streamToPrint->BaseStream property to 0. In the event handler for the pd_PrintPage event, set the position of the streamToPrint->BaseStream property to 0. In the event handler for the pd_BeginPrint event, set the position of the streamToPrint->BaseStream property to 0. Answer: D QUESTION 134: A Windows Forms application includes resources that are localized for several languages. You want to view your application when it uses resources that are localized for the French language as spoken in France. This culture is denoted by the culture name fr-FR. You need to test the application by using the resources contained in the satellite assembly. You must not modify the regional settings of your computer. What should you do? Set the following assembly attribute.[assembly: NeutralResourcesLanguage("fr-FR")]; Add the following code to the application initialization.RegionInfo^ ri = gcnew RegionInfo("FR"); Thread::CurrentThread->Name = ri->NativeName; Add the following code to the application initialization.Thread::CurrentThread->CurrentUICulture = gcnew CultureInfo("fr-FR"); D. Add the following code to the applicationSettings section of the application configuration file. "fr-FR" Answer: C

Related Downloads
Explore
Post your homework questions and get free online help from our incredible volunteers
  575 People Browsing
 145 Signed Up Today
Your Opinion