GridViewMaskBoxColumn and standart mask.

3 posts, 0 answers
  1. Jose Mejia
    Jose  Mejia avatar
    107 posts
    Member since:
    May 2009

    Posted 11 Jul 2013 Link to this post

    Hi.

    For now I'm using GridViewMaskBoxColumn with standart mask type and 00°00'00.00000'' as a mask.
    I also changed promt char to 0:
    private void CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
     {
      RadMaskedEditBoxEditor editor = e.ActiveEditor as RadMaskedEditBoxEditor;
      if (editor != null)
      {
          editor.MaskTextBox.PromptChar = '0';
               
      }
     
    ...
    }


    The requirements has changed and now I need to show + or -  before the mask so it should look like
    +00°00'00.00000''. The most easiest way is to use #00°00'00.00000'', but in this case when I start edit
    masktextbox looks like 000°00'00.00000'' which is very inconvenient. So I need some how to provide possibility to let use enter (choose)
    + or - and preserve the old mask (00°00'00.00000''). The regex is also not very convenient.

    Is the any possibility to provide selection of a sign for standart mask?

    My control version is 2011.2.11.831

    Thanks in advance.

  2. Jose Mejia
    Jose  Mejia avatar
    107 posts
    Member since:
    May 2009

    Posted 11 Jul 2013 Link to this post

    Ok, I somehow solved this problem.This thread can be closed...
  3. Peter
    Admin
    Peter avatar
    1157 posts

    Posted 11 Jul 2013 Link to this post

    Hello Jose,

    I am happy that you found a solution for this.

    I would like to propose to use "#00°00'00.00000" mask and handle the RadMaskEditBox's KeyPress event if user enters a number in the first position:
    editor.MaskedEditBox.KeyPress
    -= 
    new KeyPressEventHandler(MaskedEditBoxElement_KeyPress);

    editor.MaskedEditBox.KeyPress
    +=
    new KeyPressEventHandler(MaskedEditBoxElement_KeyPress);
     
    void MaskedEditBoxElement_KeyPress(object sender, KeyPressEventArgs e)
    {
             if (char.IsDigit(e.KeyChar) && this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.SelectionStart == 0)
             {
                  e.Handled = true;
             }
    }

    I hope you find this useful.

    Regards,
    Peter
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top