Ticket Q249050
Visible to All Users

Decimal point is comma on numeric keypad

created 15 years ago

Hi,
On the numeric keypad there is a button (Del or . ).
Pressing this button in MS_Excel it gives back a , instead of a . in numeric fields.
Is it possible to get this behaviour for the whole application without writing code in every form?
Thanks for your help.
With regards,
Frits van Ooijen

Answers approved by DevExpress Support

created 15 years ago (modified 11 years ago)

Hi Frits,
This problem doesn't directly relate to our components. It is widely discussed on the Internet. For example, please see the following link:
dot vs comma
As a possible solution, I suggest that you use the editor's numeric mask, and set the NumberFormatInfo.NumberDecimalSeparator property to a necessary character.
See the attached sample.
Thanks
Dimitros

    Show previous comments (1)
    Anatol (DevExpress) 15 years ago

      Hello Frits,
      You are right, most likely, you'll have to customize some controls in your application individually, to apply this solution. However, please note that it is enough to set the culture settings, such as NumberDecimalSeparator, only once, when the application is started, as shown in the following code:

      C#
      CultureInfo culture = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.Name, true); culture.NumberFormat.NumberDecimalSeparator = ","; System.Threading.Thread.CurrentThread.CurrentCulture = culture;

      Please let me know if you need any further help.
      Thanks,
      Anatol

        Hi Anatol,
        I found a workaround that works for me.
        In the attached sample I did the following:
             Create a form called <Basis> which inherits from
                  public partial class Basis : DevExpress.XtraEditors.XtraForm
             In design of the form basis set the option KeyPreview to true
             Make a event on KeyDown
                  private void Basis_KeyDown(object sender, KeyEventArgs e)
                  {
                       if (e.KeyData == Keys.Decimal)
                       {
                            e.SuppressKeyPress = true;
                            SendKeys.Send(",");
                       }
                  }
             The MDI-Children inherits
              public partial class Form1 : Basis
        Now the decimal key on the numeric keyboard gives always a , instead of a . character.
        It works on a textbox and on a gridview.
        Is there any reason why I shouldn’t implement this in my application.
        With regards,
        Frits van Ooijen

        Anatol (DevExpress) 15 years ago

          Hello Frits,
          I've tested your solution, and found only one situation when it doesn't work: with this design, our MaskManager cannot correctly handle the decimal separator pressing, and you are able to make two decimal separators within a single field. As a result, the validation error will occur when you try to leave the field. I don't know whether it is a serious problem for you.
          I should also add that with my culture settings (en-us), it is still required to change the NumberDecimalSeparator property, to make this solution work.
          Thanks,
          Anatol

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.