Microsoft .NET Framework 2.0 - Quetions Answers - 070-526

Microsoft .NET Framework 2.0 - Quetions Answers - 070-526

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


A. For the Validating event of dtpStartDate, create an event handler named
VerifyStartDate.
B. For the Validated event of dtpStartDate, create an event handler named
VerifyStartDate.
C. In the Properties Window for dtpStartDate, set the value of Error on erpErrors to Date out of range.
D. In VerifyStartDate, call erpErrors->SetError(dtpStartDate, "Date out of range") if the value of dtpStartDate->Value is greater than today's date.
E. In VerifyStartDate, call erpErrors->SetError(dtpStartDate, "") if the value of
dtpStartDate->Value is greater than today's date.
Answer: A,E


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?
A. Dim str As String = String.Format("Column was {0} is now {1}", row(col), row(col,
DataRowVersion.Current))
B. Dim str As String = String.Format("Column was {0} is now {1}", row(col,
DataRowVersion.Default), row(col))
C. Dim str As String = String.Format("Column was {0} is now {1}", row(col), row(col,
DataRowVersion.Proposed))
D. Dim str As String = String.Format("Column was {0} is now {1}", row(col,
DataRowVersion.Original), row(col))
Answer: D


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)
B. dt.Compute("UnitPrice * Quantity", "ItemSubtotal")
C. 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


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. Me.DataBindings.Add("chkIsManager.Checked", ds, "Users.IsManager")
Answer: A


the SqlDataAdapter object.
Reload the dataset in an event handler that is registered for the OnChanged event of the
SqlDendency object.
B. Use a TransactionScope block when calling the Fill method of the SqlDataAdapter
object.
C. Set the CommandTimeout property of the SqlCommand object that is used by the
SqlDataAdapter object to -1.
D. Reload the data table in an event handler that is registered for the RowChanging event
of the DataTable object.
Answer: A

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 hat 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


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: void StartBackgroundWorkerProcess() { bgwExecute->DoWork += gcnew
Do WorkEventHandler(this, &Form1::WorkHandler);
bgwExecute->RunWorkerCompleted += gcnew
Run WorkerCompletedEventHandler(this, &Form1::CompletedHandler);
bgwExecute->RunWorkerAsync();
}
B. private: void StartBackgroundWorkerProcess() { bgwExecute->ProgressChanged +=
gcnew progressChangedEventHandler(this, &Form1::CompletedHandler);
ThreadStart^ tsBackground = gcnew ThreadStart(this, &Form1::CompletedHandler);
bgwExecute->RunWorkerAsync(tsBackground);
}
C. 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;
}
E. void WorkHandler(Object^ sender, DoWorkEventArgs^ e) { // ...
bgwExecute->ReportProgress(100, tru);
}
F. void CompletedHandler(Object^ sender, RunWorkerCompletedEventArgs^ e){ bool
result = (bool)e->Result;
MessageBox::Show("Update " + (result ? "was successful" : "failed"));
}
G. void CompletedHandler(Object^ sender, ProgressChangedEventArgs^ e){ bool result
= (bool)e->UserState;
MessageBox::Show("Update " + (result ? "was successful" : "failed"));
}
Answer: A,D,F


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.
A. Set the PrinterSettings.PrinterName property of the PrintDocument control to
Preview.
B. 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


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?
A. In the event handler for the ppd.Click event, set the position of the
streamToPrint.BaseStream property to 0.
B. In the event handler for the ppd.PrintPreviewControl.Click event, set the
position of the streamToPrint.BaseStream property to 0.
C. In the event handler for the pd.PrintPage event, set the position of the
streamToPrint.BaseStream property to 0.
D. In the event handler for the pd.BeginPrint event, set the position of the
streamToPrint.BaseStream property to 0.
Answer: D

Share this

Related Posts

There was an error in this gadget