473,805 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.KeyEvent Args.KeyCode' cannot be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTim ePicker : DateTimePicker {

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

Jun 27 '08 #1
3 3136
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

KeyPressEventAr gs ea = new KeyPressEventAr gs(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******** ******@TK2MSFTN GP03.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.KeyEvent Args.KeyCode' cannot be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTim ePicker : DateTimePicker {

protected override void OnKeyDown(KeyEv entArgs 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

KeyPressEventAr gs ea = new KeyPressEventAr gs(KeyChar.F4)
base.OnKeyPress (ea);

I tried

protected override void OnKeyPress(KeyP ressEventArgs e)
{
if (e.KeyChar == (char)Keys.F12)
{
KeyPressEventAr gs ea = new KeyPressEventAr gs((char)Keys.F 4);
base.OnKeyPress (ea);
return;
}

and

protected override void OnKeyDown(KeyEv entArgs e)
{
if (e.KeyCode == Keys.F12)
{
KeyPressEventAr gs ea = new KeyPressEventAr gs((char)Keys.F 4);
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******** ******@TK2MSFTN GP03.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.KeyEvent Args.KeyCode' cannot be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTim ePicker : DateTimePicker {

protected override void OnKeyDown(KeyEv entArgs 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******** *******@TK2MSFT NGP03.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

KeyPressEventA rgs ea = new KeyPressEventAr gs(KeyChar.F4)
base.OnKeyPres s(ea);


I tried

protected override void OnKeyPress(KeyP ressEventArgs e)
{
if (e.KeyChar == (char)Keys.F12)
{
KeyPressEventAr gs ea = new
KeyPressEventAr gs((char)Keys.F 4);
base.OnKeyPress (ea);
return;
}

and

protected override void OnKeyDown(KeyEv entArgs e)
{
if (e.KeyCode == Keys.F12)
{
KeyPressEventAr gs ea = new
KeyPressEventAr gs((char)Keys.F 4);
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******* *******@TK2MSFT NGP03.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.KeyEvent Args.KeyCode' cannot
be
assigned to -- it is read only

How to fix ?

Andrus.

public class NullableDateTim ePicker : DateTimePicker {

protected override void OnKeyDown(KeyEv entArgs 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
2759
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 searched this forum high and low to find a solution and have tried virtually everything mentioned, all to no avail. Some solutions even crash the computer. Does anyone have any ideas? Thanks TD
1
2593
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 the column in the DataSet table consist of DateTime value. I also have two DateTimePicker (startDate and endDate) on my Windows form.
0
2241
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. The program is running on an IIS 5.0 and coded with ASP.NET (C#). On the developing computer if could open the calendar folder of user who was entered in the MAPi profile of Windows.
0
1485
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
4576
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 they click "Update Calendar" I want to force the DayRender events to reprocess. I don't want to simply do a response.redirect to the page. Thanks.
0
293
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 to create an application in visual basice. http://msdn.microsoft.com/library/en-us/vsintro7/html/vxwlkwalkthroughcreatingwebapplicationusingvisualcorvisualbasic.asp I've setup everything nearly the same as in the walkthrough. I'm using a...
13
51718
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 than try to open it? Thankss
1
1526
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 (from regional settings) in same format i.e. dd/MM/yyy but if I set it on another format, the control's text property doesn't get user value. Is there any solution.
2
1732
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 ? -- Adrian Parker Ingenuity At Work Ltd
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.