What should you do to implement a context menu that provides this functionality?

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?

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

B.
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;

C.
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();
}

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



Leave a Reply 0

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