Date: 2009-9-17 10:58 Author: pass4line Click: 62
Microsoft 70-526 CSharp free demo show:
1. 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.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?
A. string str = String.Format("Column was {0} is now {1}",
row[col],
row[col, DataRowVersion.Current]);
B. string str = String.Format("Column was {0} is now {1}",
row[col, DataRowVersion.Default],
row[col]);
C. string str = String.Format("Column was {0} is now {1}",
row[col],
row[col, DataRowVersion.Proposed]);
D. string str = String.Format("Column was {0} is now {1}",
row[col, DataRowVersion.Original],
row[col]);
Answer: D
2. 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, 50F));
pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 100F));
pnlLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
B. pnlLayout.ColumnStyles[0].Width = 50F;
pnlLayout.ColumnStyles[0].SizeType = SizeType.Absolute;
pnlLayout.ColumnStyles[2].Width = 50F;
pnlLayout.ColumnStyles[2].SizeType = SizeType.Absolute;
C. pnlLayout.ColumnStyles[0].Width = 50F;
pnlLayout.ColumnStyles[0].SizeType = SizeType.Absolute;
pnlLayout.ColumnStyles[1].Width = 100F;
pnlLayout.ColumnStyles[1].SizeType = SizeType.AutoSize;
pnlLayout.ColumnStyles[2].Width = 50F;
pnlLayout.ColumnStyles[2].SizeType = SizeType.Absolute;
D. 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
3. 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.
D. In the Properties Window for dtpStartDate, set the value of Error on erpErrors to Date out of range.
E. In VerifyStartDate, call erpErrors.SetError(dtpStartDate, "Date out of range") if the value of dtpStartDate.Value is greater than today's date.
F. In VerifyStartDate, call erpErrors.SetError(dtpStartDate, null) if the dtpStartDate.Value is greater than today's date.
Answer: AE
4. 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.
MonthCalendar cal = new MonthCalendar();
ContextMenuStrip mnuContext = new ContextMenuStrip();
ToolStripControlHost host = new
ToolStripControlHost(mnuContext);
txtDate.ContextMenuStrip = mnuContext;
B. Add the following code to the form initialization.
ContextMenuStrip mnuContext = new ContextMenuStrip();
MonthCalendar cal = new MonthCalendar();
ToolStripControlHost host = new
ToolStripControlHost(cal);
mnuContext.Items.Add(host);
txtDate.ContextMenuStrip = mnuContext;
C. Add the following code to the form initialization.
ToolStripContainer ctr = new ToolStripContainer();
MonthCalendar cal = 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) {
txtDate.Controls[0].Show();
}
D. Add a MouseClick event handler for the TextBox control that contains the following code.
if (e.Button == MouseButtons.Right) {
ContextMenuStrip mnuContext = new ContextMenuStrip();
MonthCalendar cal = new MonthCalendar();
ToolStripControlHost host = new
ToolStripControlHost(cal);
mnuContext.Items.Add(host);
txtDate.ContextMenuStrip = mnuContext;
}
Answer: B
5. 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?
A. Add the following code to the form initialization.
foreach (Control ctl in this.Controls) {
if (ctl is Button){
ctl.Click += new EventHandler(ctl_Click);
}
}
B. Add the following code to the form initialization.
this.Click += new EventHandler(ctl_Click);
C. Use the Properties dialog box to set the Click event for each Button control on the form to the ctl_Click method.
D. Use the Properties dialog box to set the Click event of the form to the ctl_Click method.
Answer: A
5. 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?
A. ToolStripMenuItem mnuItem = (ToolStripMenuItem)sender;
LogClick(mnuItem.Text);
B. LogClick(e.ToString());
C. LogClick(this.Text);
D. ToolStripMenuItem mnuItem = (ToolStripMenuItem)
this.GetContainerControl();
LogClick(mnuItem.Text);
Answer: A
6. 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
The hot exam:70-526 VB exam and 70-680 exam and 70-526 C++ exam and 1Z0-403