PrepAway - Latest Free Exam Questions & Answers

What should you do?

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?

PrepAway - Latest Free Exam Questions & Answers

A.
Add the following code to the form initialization.Dim cal As New MonthCalendar()Dim mnuContext As New ContextMenuStrip()Dim host As New ToolStripControlHost(mnuContext)txtDate.ContextMenuStrip = mnuContext

B.
Add the following code to the form initialization.Dim mnuContext As New ContextMenuStrip()Dim cal As New MonthCalendar()Dim host As New
ToolStripControlHost(cal)mnuContext.Items.Add(host)txtDate.ContextMenuStrip = mnuContext

C.
Add the following code to the form initialization.Dim ctr As New ToolStripContainer()Dim cal As 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 Then txtDate.Controls(0).Show()End If

D.
Add a MouseClick event handler for the TextBox control that contains the following code.If e.Button = MouseButtons.Right Then Dim mnuContext As New ContextMenuStrip() Dim cal As New MonthCalendar() Dim host As New ToolStripControlHost(cal) mnuContext.Items.Add(host) txtDate.ContextMenuStrip = mnuContextEnd If


Leave a Reply