| | |
How to add DateTimePicker to ToolStrip ?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
You can place just about anything on the toolstrip.
First (in the IDE) place the desired component on the form (anywhere will do).
Provide yourself with a ToolStripControlHost type variable.
Then when the form in instantiated, do this:
dtMyDateTimePicker is the component you dropped on the form, and eventually want to live on the tool strip. The hosting variable is instantiated and takes dtMyDateTimePicker as its child. When the new host is added to the toolstrip, the datetime picker goes with it.
You can set the properties of the toolstrip collection and the dtTScomponent properties to get the desired appearance. From that point on, you do not need to refer to the dtTScomponent for anything... it is just a host.
First (in the IDE) place the desired component on the form (anywhere will do).
Provide yourself with a ToolStripControlHost type variable.
Then when the form in instantiated, do this:
C# Syntax (Toggle Plain Text)
private ToolStripControlHost dtTScomponent; public form1() { InitializeComponent(); dtTScomponent = new ToolStripControlHost(dtMyDateTimePicker); MainToolStrip.Items.Add(dtTScomponent); }
dtMyDateTimePicker is the component you dropped on the form, and eventually want to live on the tool strip. The hosting variable is instantiated and takes dtMyDateTimePicker as its child. When the new host is added to the toolstrip, the datetime picker goes with it.
You can set the properties of the toolstrip collection and the dtTScomponent properties to get the desired appearance. From that point on, you do not need to refer to the dtTScomponent for anything... it is just a host.
•
•
Join Date: Dec 2007
Posts: 41
Reputation:
Solved Threads: 0
•
•
•
•
You can place just about anything on the toolstrip.
First (in the IDE) place the desired component on the form (anywhere will do).
Provide yourself with a ToolStripControlHost type variable.
Then when the form in instantiated, do this:
C# Syntax (Toggle Plain Text)
private ToolStripControlHost dtTScomponent; public form1() { InitializeComponent(); dtTScomponent = new ToolStripControlHost(dtMyDateTimePicker); MainToolStrip.Items.Add(dtTScomponent); }
dtMyDateTimePicker is the component you dropped on the form, and eventually want to live on the tool strip. The hosting variable is instantiated and takes dtMyDateTimePicker as its child. When the new host is added to the toolstrip, the datetime picker goes with it.
You can set the properties of the toolstrip collection and the dtTScomponent properties to get the desired appearance. From that point on, you do not need to refer to the dtTScomponent for anything... it is just a host.
Thank you pal it work Correctly
it same...
here is the code for vb :
here is the code for vb :
vb.net Syntax (Toggle Plain Text)
Private dtTScomponent As ToolStripControlHost Public Sub New() InitializeComponent() dtTScomponent = New ToolStripControlHost(dtMyDateTimePicker) MainToolStrip.Items.Add(dtTScomponent) End Sub
Last edited by Jx_Man; May 4th, 2008 at 12:03 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Other Threads in the C# Forum
- Previous Thread: Saving text manipulated data
- Next Thread: random generation
| Thread Tools | Search this Thread |
.net access ado.net algorithm appportability array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql native networking operator path photoshop picturebox pixelinversion pixelminversion post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






