[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Avoid typing in Datepicker text

Posted on 2011-09-27
6
Medium Priority
?
726 Views
Last Modified: 2013-11-12
Hi All,
Advance thanks.
I am using Datepicker control in UI. Would need to restrict user only to select the date from the dropdown calender. Now when the user types in any characters in the text, it get stayed and i don't know how to clean the text. Is there any way to restrict the user not to type in anything in the text area.

Kind regards,
Pooja
0
Comment
Question by:poojasureshkumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 total points
ID: 36711058
Cancel the key in the KeyPress event. Maybe add a beep so that the user as some feedback.

Private Sub DateTimePicker1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles DateTimePicker1.KeyPress
   e.Handled = True
   Microsoft.VisualBasic.Beep()
End Sub

Open in new window

0
 

Author Closing Comment

by:poojasureshkumar
ID: 36711428
Excellent.
0
 

Author Comment

by:poojasureshkumar
ID: 36718538
Hi James,
It is working fine  for first time. I mean, it is disallowing the user not to type in anything in the  text first. But allow them to enter text after the date is picked from the calendar.

Kind regards,
Pooja
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40
ID: 36718813
You added something somewhere.

Attached is a simple form that shows the concept, and they cannot type in even after making a selection. Form1.zip
0
 

Author Comment

by:poojasureshkumar
ID: 36720062
Hi James,
Am using SL4. This is my code

   Private Sub DateTimePicker_KeyPress(ByVal sender As Object, ByVal e As KeyEventArgs)
        If Not e.PlatformKeyCode = 9 Then e.Handled = True
    End Sub

Kind regards,
Pooja

0
 
LVL 40
ID: 36720448
The code would be the same.

If the keypress cancels everything except a tabulation (that is what the 9 stands for, isn't it?) before selecting a date, it should continue to do the same after.

If you put a breakpoint in the KeyPress, is it still hit after the selection?

If so, there is no reason why the code would not still work.

If not, then something broke the link between the event and the event procedure. I am sorry, but I do not know how the procedure is linked to the event in Silverlight.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question