943,910 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 11328
  • C# RSS
Feb 20th, 2008
0

How to add DateTimePicker to ToolStrip ?

Expand Post »
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

Reputation Points: 10
Solved Threads: 0
Light Poster
IT_Techno is offline Offline
41 posts
since Dec 2007
Feb 20th, 2008
0

Re: How to add DateTimePicker to ToolStrip ?

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)
  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.
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006
Feb 23rd, 2008
0

Re: How to add DateTimePicker to ToolStrip ?

Click to Expand / Collapse  Quote originally posted by JerryShaw ...
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)
  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
Reputation Points: 10
Solved Threads: 0
Light Poster
IT_Techno is offline Offline
41 posts
since Dec 2007
May 3rd, 2008
0

Re: How to add DateTimePicker to ToolStrip ?

how i can do the same thing at visual basic
i have a visual studio 2005
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mfahmy2008 is offline Offline
5 posts
since May 2008
May 4th, 2008
0

Re: How to add DateTimePicker to ToolStrip ?

it same...
here is the code for vb :
vb.net Syntax (Toggle Plain Text)
  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.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,140 posts
since Nov 2007
May 4th, 2008
0

Re: How to add DateTimePicker to ToolStrip ?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mfahmy2008 is offline Offline
5 posts
since May 2008
May 4th, 2008
0

Re: How to add DateTimePicker to ToolStrip ?

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
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Saving text manipulated data
Next Thread in C# Forum Timeline: random generation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC