Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Disable direct edit in TDateEdit
Sat, Jun 26 2021 7:40 AMPermanent Link

StewCam

I wanted to disable direct edit in TDateEdit, so that the user is forced to select a date from the drop down calendar. I found that if I set the OnEnter and OnExit handlers to disable and enable the control respectively, I get the desired effect. However, this feels like a workaround. Is there a more straightforward way?
Sun, Jun 27 2021 7:09 PMPermanent Link

Alan Questell

Richmond Community College

You want to handle the OnKeyDown event and then you can discard anything you want.  You can examine Key pressed and discard any that you want to discard.

StewCam wrote:

I wanted to disable direct edit in TDateEdit, so that the user is forced to select a date from the drop down calendar. I found that if I set the OnEnter and OnExit handlers to disable and enable the control respectively, I get the desired effect. However, this feels like a workaround. Is there a more straightforward way?
Mon, Jun 28 2021 8:19 AMPermanent Link

StewCam

Thanks for the suggestion. Handling the OnKeyDown is neater. However, the blinking edit cursor and the deletion button (X) are then enabled, which is potentially confusing.                

Alan Questell wrote:

You want to handle the OnKeyDown event and then you can discard anything you want.  You can examine Key pressed and discard any that you want to discard.
Mon, Jun 28 2021 2:47 PMPermanent Link

Alan Questell

Richmond Community College

Have you considered an edit control that's read only and then update it from your program when a date is chosen from a calendar control?  In other words, break this into two instead of trying to use the one.

StewCam wrote:

Thanks for the suggestion. Handling the OnKeyDown is neater. However, the blinking edit cursor and the deletion button (X) are then enabled, which is potentially confusing.                

Alan Questell wrote:

You want to handle the OnKeyDown event and then you can discard anything you want.  You can examine Key pressed and discard any that you want to discard.
Tue, Jun 29 2021 7:24 AMPermanent Link

StewCam

Thanks again. In this case I am looking to conserve space in the layout, so will stick with handling OnEnter and OnExit for now.

Alan Questell wrote:

Have you considered an edit control that's read only and then update it from your program when a date is chosen from a calendar control?  In other words, break this into two instead of trying to use the one.
Image