How to add DateTimePicker to ToolStrip ?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 41
Reputation: IT_Techno is an unknown quantity at this point 
Solved Threads: 0
IT_Techno IT_Techno is offline Offline
Light Poster

How to add DateTimePicker to ToolStrip ?

 
0
  #1
Feb 20th, 2008
hi every one

i need help . How to add DateTimePicker to ToolStrip in my windows form ?

if any one can help

Nice Thanks,

IT_Techno

Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: How to add DateTimePicker to ToolStrip ?

 
0
  #2
Feb 20th, 2008
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:
  1.  
  2. private ToolStripControlHost dtTScomponent;
  3.  
  4. public form1()
  5. {
  6. InitializeComponent();
  7. dtTScomponent = new ToolStripControlHost(dtMyDateTimePicker);
  8. MainToolStrip.Items.Add(dtTScomponent);
  9. }

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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 41
Reputation: IT_Techno is an unknown quantity at this point 
Solved Threads: 0
IT_Techno IT_Techno is offline Offline
Light Poster

Re: How to add DateTimePicker to ToolStrip ?

 
0
  #3
Feb 23rd, 2008
Originally Posted by JerryShaw View Post
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:
  1.  
  2. private ToolStripControlHost dtTScomponent;
  3.  
  4. public form1()
  5. {
  6. InitializeComponent();
  7. dtTScomponent = new ToolStripControlHost(dtMyDateTimePicker);
  8. MainToolStrip.Items.Add(dtTScomponent);
  9. }

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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: mfahmy2008 is an unknown quantity at this point 
Solved Threads: 0
mfahmy2008 mfahmy2008 is offline Offline
Newbie Poster

Re: How to add DateTimePicker to ToolStrip ?

 
0
  #4
May 3rd, 2008
how i can do the same thing at visual basic
i have a visual studio 2005
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: How to add DateTimePicker to ToolStrip ?

 
0
  #5
May 4th, 2008
it same...
here is the code for vb :
  1. Private dtTScomponent As ToolStripControlHost
  2. Public Sub New()
  3. InitializeComponent()
  4. dtTScomponent = New ToolStripControlHost(dtMyDateTimePicker)
  5. MainToolStrip.Items.Add(dtTScomponent)
  6. 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 *
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: mfahmy2008 is an unknown quantity at this point 
Solved Threads: 0
mfahmy2008 mfahmy2008 is offline Offline
Newbie Poster

Re: How to add DateTimePicker to ToolStrip ?

 
0
  #6
May 4th, 2008
thank you very much about your reply
but how i can do the same thing at design time
you know of course the toolstrip only contain text label combobox button and not contain radio button datetimepicker etc
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: How to add DateTimePicker to ToolStrip ?

 
0
  #7
May 4th, 2008
The only way I know of to do this at design time is to create a new component that is a subclass of ToolStrip, and then add the extra functionality. Use your new component instead of the ToolStrip.

// Jerry
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC