Adding an event handler to a toolstrip control

Hoser

Member
Joined
Mar 11, 2007
Messages
11
Programming Experience
1-3
I have added a DateTimePicker to a tool strip but I am having difficulty in getting the date selected back(no event handler). Anyone know how I can do this, Below is a copy of my code:

' Create a new ToolStripControlHost, passing in a control.
ArrivalDateTimePickerHost = New ToolStripControlHost(New DateTimePicker())
ArrivalDateTimePickerHost.AutoSize =
False
ArrivalDateTimePickerHost.Alignment = ToolStripItemAlignment.Right
'ArrivalDateTimePickerHost.Font = New Font("Arial", 9, FontStyle.Italic)
ArrivalDateTimePickerHost.Width = 220
ArrivalDateTimePickerHost.DisplayStyle = ToolStripItemDisplayStyle.Text

CType(ArrivalDateTimePickerHost.Control, DateTimePicker).Format = DateTimePickerFormat.Long
ArrivalDateTimePickerHost.Control.Name =
"dtpArrival"
' Add the control host to the ToolStrip.
ToolStrip1.Items.Add(ArrivalDateTimePickerHost)


Regards:confused:
 
Either declare the DTP WithEvents outside the method you set up the tool strip, or Dim it first and use AddHandler statement to add the event handler.
 
Back
Top