473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Force DataTimePicker to open calendar by F12

I need that WinForms DateTimePicker opens calendar when F12 key is pressed.
I tried code below but got error

Property or indexer 'System.Windows.Forms.KeyEventArgs.KeyCode' cannot be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTimePicker : DateTimePicker {

protected override void OnKeyDown(KeyEventArgs e) {
base.OnKeyDown(e);
if (e.KeyCode == Keys.F12)
e.KeyCode = Keys.F4;
}
}

Jun 27 '08 #1
3 3119
I am not understanding why you would need to set the KeyCode to something
else, if all you want to do is open the DateTimePicker.

If you absolutely need to pass down to base, you can create an EventArg

KeyPressEventArgs ea = new KeyPressEventArgs(KeyChar.F4)
base.OnKeyPress(ea);

But, I would think you can pop the control without intercepting the
keystroke.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Andrus" <ko********@hot.eewrote in message
news:uR**************@TK2MSFTNGP03.phx.gbl...
>I need that WinForms DateTimePicker opens calendar when F12 key is pressed.
I tried code below but got error

Property or indexer 'System.Windows.Forms.KeyEventArgs.KeyCode' cannot be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTimePicker : DateTimePicker {

protected override void OnKeyDown(KeyEventArgs e) {
base.OnKeyDown(e);
if (e.KeyCode == Keys.F12)
e.KeyCode = Keys.F4;
}
}
Jun 27 '08 #2
Gregory,
>I am not understanding why you would need to set the KeyCode to something
else, if all you want to do is open the DateTimePicker.
They is no method or property which can be used to open calendar so I tried
this as last effort.
If you absolutely need to pass down to base, you can create an EventArg

KeyPressEventArgs ea = new KeyPressEventArgs(KeyChar.F4)
base.OnKeyPress(ea);

I tried

protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.F12)
{
KeyPressEventArgs ea = new KeyPressEventArgs((char)Keys.F4);
base.OnKeyPress(ea);
return;
}

and

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.F12)
{
KeyPressEventArgs ea = new KeyPressEventArgs((char)Keys.F4);
base.OnKeyPress(ea);
return;
}

but F12 still does not open calendar.
But, I would think you can pop the control without intercepting the
keystroke.
Which method or property I should use for this ?

Andrus.
"Andrus" <ko********@hot.eewrote in message
news:uR**************@TK2MSFTNGP03.phx.gbl...
>>I need that WinForms DateTimePicker opens calendar when F12 key is
pressed.
I tried code below but got error

Property or indexer 'System.Windows.Forms.KeyEventArgs.KeyCode' cannot be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTimePicker : DateTimePicker {

protected override void OnKeyDown(KeyEventArgs e) {
base.OnKeyDown(e);
if (e.KeyCode == Keys.F12)
e.KeyCode = Keys.F4;
}
}
Jun 27 '08 #3
Try using SendKeys to send it an F4.

Look up SendKeys in the help.
"Andrus" <ko********@hot.eewrote in message
news:%2***************@TK2MSFTNGP03.phx.gbl...
Gregory,
>>I am not understanding why you would need to set the KeyCode to something
else, if all you want to do is open the DateTimePicker.

They is no method or property which can be used to open calendar so I
tried
this as last effort.
>If you absolutely need to pass down to base, you can create an EventArg

KeyPressEventArgs ea = new KeyPressEventArgs(KeyChar.F4)
base.OnKeyPress(ea);


I tried

protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.F12)
{
KeyPressEventArgs ea = new
KeyPressEventArgs((char)Keys.F4);
base.OnKeyPress(ea);
return;
}

and

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.F12)
{
KeyPressEventArgs ea = new
KeyPressEventArgs((char)Keys.F4);
base.OnKeyPress(ea);
return;
}

but F12 still does not open calendar.
>But, I would think you can pop the control without intercepting the
keystroke.

Which method or property I should use for this ?

Andrus.
>"Andrus" <ko********@hot.eewrote in message
news:uR**************@TK2MSFTNGP03.phx.gbl...
>>>I need that WinForms DateTimePicker opens calendar when F12 key is
pressed.
I tried code below but got error

Property or indexer 'System.Windows.Forms.KeyEventArgs.KeyCode' cannot
be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTimePicker : DateTimePicker {

protected override void OnKeyDown(KeyEventArgs e) {
base.OnKeyDown(e);
if (e.KeyCode == Keys.F12)
e.KeyCode = Keys.F4;
}
}
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to the specific date on the first form. I have...
1
by: Soul | last post by:
*** I am not sure this question belong to *.languages.csharp or *.framework.windowsdorms.databinding, so I post to both *** Hi, Currently I have a DataGrid which bind to a DataSet. One of...
0
by: Jens | last post by:
Hi to all ! I have a question concerning the OUTLOOK interop. I managed to read users from the AD and put them in a treeview. The next step is to open the Calendar of a User in a new Window....
0
by: VB Programmer | last post by:
How do I force a Calendar to "re-process" without having to do a response.redirect to the page. Specifically I want to run the DayRender event of the Calendar.
2
by: VB Programmer | last post by:
How can I force the DayRender event of my Calendar to run/refresh? The calendar displays data from a database and I am allowing the user to filter out what data they see on the calendar. When...
0
by: KJBaham | last post by:
Hi, I've created many MS Access databases that report info from a DB2/400 system here, and I am trying to learn to put these into web applications. I am using the following walkthrough as a guide...
13
by: ron1972 | last post by:
Hi I have a large pdf file that if I create an anchor link to, the browser will try to open the file, which takes quite a long time. Is there a way to force the browser to download the file rather...
1
by: h | last post by:
Hi, I am binding datetimepicker control in vb.net 2005, I set following property for the control. format -> custom, customformat -> dd/MM/yyy, Above control runs well if I set my system date...
2
by: Adrian Parker | last post by:
We have a date control (textbox) that opens up a popup calendar window, how, when that calendar returns with the selected value can I cause the changed event to fire on the date control ? --...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.