Which code segment should you use?

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

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

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



Leave a Reply 0

Your email address will not be published. Required fields are marked *