| | |
How to add DateTimePicker to ToolStrip ?
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 animation array bitmap box c# check checkbox client combobox control conversion csharp customactiondata database datagrid datagridview dataset date/time datetime datetimepicker degrees directrobot display dll draganddrop drawing encryption enum excel file filename files form format formbox forms formupdate function gdi+ gtk hash image input install java leak list math mouseclick mp3 mysql native networking operator outlook2003 packaging path photoshop picturebox pixelinversion pixelminversion post print process programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wfa wia winforms wpf xml






