locked
How can I call the TextBox KeyPress event in LightSwitch RRS feed

  • Question

  • Hi All,

    I have textboxes for Latitude and Longitude. As you know that for both of these we have 2 precise and 6 scale digits. How can I set these for the textboxes. ??

    Best,


    Inayat Rehman

    Friday, August 10, 2012 12:08 PM

Answers

  • Dear Lionwin,

    I want to restirct the user to only 8 digits with 6 decimal points and that can't be done using this method. If you provide me any other solution that would be great..

    Best,


    Inayat Rehman

    Ok this is easily can be done by custom validation of the text box

    Please refer to the best article "by beth massi"

    http://blogs.msdn.com/b/bethmassi/archive/2011/11/11/common-validation-rules-in-lightswitch-business-applications.aspx

    you can use the the regular expression by importing:

    Imports System.Text.RegularExpressions

    and as explained in the article


    ----------------------------------- If My replay is helpful Please vote

    • Proposed as answer by lionwin8 Friday, August 10, 2012 3:02 PM
    • Marked as answer by Dino HeModerator Thursday, August 16, 2012 5:34 AM
    Friday, August 10, 2012 2:43 PM

All replies

  • Try this:

    partial void <Screen>_Created()
    {
        var proxy = this.FindControl("controlName");
        proxy.ControlAvailable += new EventHandler<ControlAvailableEventArgs>((s, e) =>
        {
            System.Windows.Controls.TextBox textbox = e.Control as System.Windows.Controls.TextBox;
             textbox.KeyDown += new EventHandler<System.Windows.Input.KeyEventArgs>((s1, e1) =>
             {
    		//...
                    //e1.Handled = true;
              });
         });
    }

    Friday, August 10, 2012 12:46 PM
  • Thanks Ninoid for the reply, I have already tried the above code. In this you can only access the keyboard keys one by one using the key enum.

    I want my textbox  to accept the value like 98.897365, i.e. Latitude and Longitude, Please help me in this.

    Best,


    Inayat Rehman

    Friday, August 10, 2012 1:15 PM
  • Hi All,

    I have textboxes for Latitude and Longitude. As you know that for both of these we have 2 precise and 6 scale digits. How can I set these for the textboxes. ??

    Best,


    Inayat Rehman

    dear you can check the following link

    http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/aca9569a-e923-4acf-9ec8-acf972681ef2


    ----------------------------------- If My replay is helpful Please vote

    Friday, August 10, 2012 1:22 PM
  • Dear Lionwin,

    I want to restirct the user to only 8 digits with 6 decimal points and that can't be done using this method. If you provide me any other solution that would be great..

    Best,


    Inayat Rehman

    Friday, August 10, 2012 1:47 PM
  • Hi Inayat

    I will be better if you go for a silverlight custom control, i.e - Masked Text Box. This will definitely solve your problem.

    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.com

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    Friday, August 10, 2012 2:19 PM
  • Dear Lionwin,

    I want to restirct the user to only 8 digits with 6 decimal points and that can't be done using this method. If you provide me any other solution that would be great..

    Best,


    Inayat Rehman

    Ok this is easily can be done by custom validation of the text box

    Please refer to the best article "by beth massi"

    http://blogs.msdn.com/b/bethmassi/archive/2011/11/11/common-validation-rules-in-lightswitch-business-applications.aspx

    you can use the the regular expression by importing:

    Imports System.Text.RegularExpressions

    and as explained in the article


    ----------------------------------- If My replay is helpful Please vote

    • Proposed as answer by lionwin8 Friday, August 10, 2012 3:02 PM
    • Marked as answer by Dino HeModerator Thursday, August 16, 2012 5:34 AM
    Friday, August 10, 2012 2:43 PM
  • Thanks for the reply Babloo, I will definitly learn how to make the silverlight custom controls. Actually this is my first project in VSLS. Normally I am using VS. And these things can be easily done in Visual Studio..

    Best,


    Inayat Rehman

    Friday, August 10, 2012 2:57 PM
  • Thanks, I am sure this will solve my problem.

    Best,


    Inayat Rehman

    Friday, August 10, 2012 2:58 PM
  • Have you tried making the property a decimal value, in the table designer? You can then set both the precision & number of decimal places.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    If you find a reply helpful, please click "Vote as Helpful", if a reply answers your question, please click "Mark as Answer"
     
    By doing this you'll help people find answers faster.

    Saturday, August 11, 2012 3:07 PM
    Moderator