Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamically creating a DatePicker control

13 views
Skip to first unread message

Andi

unread,
Jan 27, 2009, 9:46:28 AM1/27/09
to
As Vista does not provide the DTPicker control by default ("mscomct2.ocx" not
installed and registered), I want to try and create the control at runtime -
and provide an alternative if it is not available.

I know it works somewhat like this:
MyUserForm.Controls.Add("System.Controls.DateTimePicker",
"SomeUniqueControlName", True)

...but I can't find out the class name of the date picker control??? What is
the correct name?

My system is Windows XP SP3 / Office 2003 and I'm working on a VBA project
in an Excel file.

Andi

unread,
Jan 27, 2009, 9:55:03 AM1/27/09
to
I've been searching for 2 hours... and now I found it five minutes after the
usenet post :P

The class name is "MSComCtl2.DTPicker". Hope it helps other people.

Karl E. Peterson

unread,
Jan 27, 2009, 2:15:40 PM1/27/09
to

Thought you said that control wasn't available, by default, on Vista?
--
.NET: It's About Trust!
http://vfred.mvps.org


Andi

unread,
Jan 28, 2009, 4:19:01 AM1/28/09
to
Exactly. That's why I try to create such a control. If it fails I'm showing a
InputBox for entering a date. But if it succeeds (Windows XP and older) the
control is shown. Anyway, getting the event handlers right is much more
complicated when creating the control dynamically.

Karl E. Peterson

unread,
Jan 28, 2009, 3:10:35 PM1/28/09
to

You might look for a UserControl wrapper around the system datepicker control.
That'd remove the need for the OCX completely. I know many folks have written
these, and I'd suspect there are a fair number out there. For example...

http://tinyurl.com/bw9hyu

or, for the wary...

http://www.planet-source-code.com/vb/scripts/BrowseCategoryOrSearchResults.asp?txtCriteria=datepicker&blnWorldDropDownUsed=TRUE&txtMaxNumberOfEntriesPerPage=10&blnResetAllVariables=TRUE&lngWId=1&B1=Quick+Search&optSort=Alphabetical

Jim Carlock

unread,
Apr 17, 2009, 7:41:41 PM4/17/09
to
"Karl E. Peterson" wrote...
: http://vfred.mvps.org/

Why not install the control from XP or wherever it comes from? Can they not get
configured with an XML Manifest file to get them loaded on Vista?

--
Jim Carlock
Naturally Cures Pink-Eye (Conjunctivitis)/Sty (Hordeolum)
http://www.associatedcontent.com/article/381336/saliva_a_natural_cure_for_conjunctivitis.html
Good at writing? Earn some money.
http://www.associatedcontent.com/join.html?refer=112327


0 new messages