|
Development | .NET Compact Framework
Free DateTimePicker for Compact Framework
Written by Carole Mitchell
[author's bio]
[read 66480 times]
Edited by Derek
Page 1
Page 2
Page 3
DateTime Picker for .NET CF
This
tutorial is written in the hopes that it might help someone
needing the datetime picker functionality get up to speed
fast without some of the hassles that I went through trying
to use the use datetime picker functionality in an application
I was writing. I was very happy to find some code on the
innovativedss.com
forums adapted by various programmers in C# (Martin Stave
and Jay Drozd) and then posted in VB.NET format by
Chani Diakidis. This is great code, but it requires
some modifications to the Load_DTPicker and creeper
functions. I found that when I had a form that needed multiple
datetime picker controls on it, I could create the first
datetime picker control without a problem, but subsequent
calls to the Load_DTPicker failed because the findWindow
api used to get the handle to the form in question failed.
Therefore the search couldn't be performed for the controls
that were to house the datetime picker functionality. What
seemed a good solution was to find the form handle before
calling Load_DTPicker, so that is what I did, and I just
passed this through to the function each time. So that problem
was solved. Next I found that when I had panels on another
panel on the form, the creeper function didn't seem to be
able to creep through all the controls on the form and find
the handles to each of the panels where the datetimepicker
was to be created. So I modified the function and it seems
to do the trick.
This step by step walkthrough and the
accompanying
.NET CF download should get you up and running in no
time at all.
Step by Step - Creating and using
the datetime picker control
1. Open Visual Studio.NET and create
a new project. Call it DateTimePicker.
2. On Form1.vb place a label and a panel
control. Change the text of the label to 'Start Date' and
change the name property of the panel to pnlStartDate.
Place another label whose text is 'End Date' and another
panel called pnlEndDate.
3. In the form1_load
event place the following code:
pnlStartDate.text = "pnlStartDate"
pnlEndDate.text = "pnlEndDate"
The panels pnlStartDate and pnlEndDate
are where the datetime picker controls are going to be created.
Their text property must be a unique string since the isDTPicker
function uses it to search for and identify the panel. The
isDTPicker function will return
the handle to the control that contains this text, and this
handle will be used to create the datetime picker control.
You should now have a form that looks
like this:

4. Add a button to this form as shown
below :

Next
Page
Back to .NET Compact Framework | [Article Index]
|