| | |
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 algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication concurrency control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






