70-526 training tools(46 to 60) for client: Mar 2016 Edition

Question No. 46

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 No. 47

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?

A. Set the SupportUrl property of your primary output to the path of the HTML document.

B. Create a Custom Install Action that calls the Process.Start method, passing in the path of the HTML document as the fileName parameter.

C. Set the PostBuild event of your installation project to the path of the HTML document.

D. 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 No. 48

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.)

A. Create a public event named UrlRequested and a property named Url for your control that returns the Url value of cboUrl.

B. Change the Modifiers property of btnGo to Public.

C. Add a DefaultEvent attribute to UrlRequest that uses the btnGo_Click event as an argument.

D. Change the Modifiers property of cboUrl to Public.

E. Raise the UrlRequested event in the Click event handler for btnGo.

Answer: AE


Question No. 49

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 DoWorkEventHandler(WorkHandler);

   bgwExecute.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedHandler);

   bgwExecute.ProgressChanged += new ProgressChangedEventHandler(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?

A. void WorkHandler(object sender, DoWorkEventArgs e) {

   if (!UpdateDB()) MessageBox.Show("Update failed");

}

B. void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) {

   if (! UpdateDB()) MessageBox.Show("Update failed");

}

C. 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) {

   if (!(bool) e.Result) bgwExecute.ReportProgress(0);

}

void ProgressChanged(object sender, ProgressChangedEventArgs e) {

   if (e.ProgressPercentage==0) MessageBox.Show("Update failed");

}

Answer: C


Question No. 50

You are creating a Windows Forms application. Your application uses a custom control. The custom control is based on a standard Windows Forms 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?

A. Decorate the read-only properties by using the EditorBrowsable attribute, and then set the EditorBrowsable attribute to EditorBrowsableState.Never.

B. Use the DesignTimeVisible attribute, and then set the DesignTimeVisible attribute to False.

C. Decorate the read-only properties by using the Browsable attribute, and then set the Browsable attribute to False.

D. Decorate the read-only properties by using the DisplayName attribute, and then set the DisplayName attribute to null.

Answer: C


Question No. 51

You are creating an installation package for a .NET Framework application. You need to configure your installation package to add a shortcut to the user's desktop during installation. Which editor in the setup project should you use?

A. File Types Editor

B. User Interface Editor

C. Custom Actions Editor

D. File System Editor

Answer: D


Question No. 52

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.MarginBounds);

B. Graphics g = this.CreateGraphics();

Bitmap formImageBitmap = CreateFormImageBitmap(g);

g.DrawImage(formImageBitmap, g.ClipBounds);

g.Dispose();

C. Graphics g = this.CreateGraphics();

Bitmap formImageBitmap = CreateFormImageBitmap(e.Graphics);

g.DrawImage(formImageBitmap, g.ClipBounds);

g.Dispose();

D. Graphics g = this.CreateGraphics();

Bitmap formImageBitmap = CreateFormImageBitmap(g);

e.Graphics.DrawImage(formImageBitmap, e.MarginBounds);

g.Dispose();

Answer: D


Question No. 53

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?

A. Configure a ToolStripContainer control to fill the form. Add the ToolStrip controls to the ToolStripContainer control.

B. Configure a Panel control to fill the form. Set the Anchor properties of the ToolStrip controls to Top, Bottom, Left, Right.

C. Add the ToolStrip controls to another ToolStrip control that is hosted by a ToolStripControlHost control.

D. 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 No. 54

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 the 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 No. 55

You are creating a Windows Forms application. Users need to preview print jobs before printing from the application. You added a PrintDocument component and PrintPreviewDialog12 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 actions should you perform? (Each correct answer presents part of the solution. Choose three.)

A. Set the PrintPreviewDialog.Document property to the PrintDocument component instance.

B. Add a PrintDialog component to the form.

C. Set the PrintDialog.Document property to the PrintDocument component instance.

D. Create an event handler for the PrintDocument.PrintPage event.

E. Call the PrintDialog.ShowDialog method.

F. Call the PrintPreviewDialog.ShowDialog method.

Answer: ADF


Question No. 56

You are creating a Windows Forms application. You create a System.Threading.Semaphore instance in the application by using the following code.

Semaphore threadPool = new Semaphore(0, 3); 

//...

threadPool.Release(4); 

What does this code do?

A. Sets the internal counter for the semaphore to 4.

B. Sets the internal counter for the semaphore to 0.

C. Throws a SemaphoreFullException.

D. Throws a ThreadAbortException.

Answer: C


Question No. 57

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?

A. chkIsManager.DataBindings.Add("Checked", ds, "Users.IsManager");

B. chkIsManager.DataBindings.Add("Checked", ds, "IsManager");

C. chkIsManager.Text = "{Users.IsManager}";

chkIsManager.AutoCheck = true;

D. this.DataBindings.Add("chkIsManager.Checked", ds, "Users.IsManager");

Answer: A


Question No. 58

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?

A. Set the InstallerClass property of your custom action to False.

B. Place the custom action in the Commit node of the Custom Actions tree rather than in the Install node.

C. Set the DetectNewerInstalledVersion property for your setup application to True.

D. Set the InstallAllUsers property for your setup application to True.

Answer: A


Question No. 59

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 Help1 and Help2 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.)

A. 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.

B. In the User Interface Editor, add a Checkboxes dialog box to the Start node of the user interface tree.

C. Use the Custom Actions Editor to add the dialog box executable for the setup application to the Install node.

D. In the Properties window for your setup project, set the PreBuildEvent property to call a command line to display the dialog box.

E. In the File System Editor, set the Condition property for Help1 to the value of the Checkbox1Property property.Set the Condition property for Help2 to the value of the Checkbox2Property property.

F. Set the Checkbox3Visible and Checkbox4Visible properties of the Checkboxes dialog box to False.

Answer: BEF


Question No. 60

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 (TransactionScope ts = new TransactionScope()) {

UpdateOrder();

UpdateAccount();

ts.Complete();

}

B. using (TransactionScope ts1 = new TransactionScope()) {

UpdateOrder();

using (TransactionScope ts2 = new TransactionScope(TransactionScopeOption.RequiresNew)) {

UpdateAccount();

ts2.Complete();

}

ts1.Complete();

}

C. using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) {

UpdateOrder();

ts.Complete();

}

using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) {

UpdateAccount();

ts.Complete();

}

D. using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) {

UpdateOrder();

}

using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) {

UpdateAccount();

ts.Complete();

}

Answer: A