Home Forums WinForms controls Xceed Grid for WinForms Fixed number of digits while editing cell

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13521 |

    Hi all.
    How can I set a format for editing a cell with a fixed number of integer and decimal digits?

    I try with

    Dim editor As New Xceed.Grid.Editors.GridNumericTextBox
    grd.Columns(“Importo”).CellEditor = editor
    grd.Columns(“Importo”).FormatSpecifier = “#,##0.00”

    But the user can write all digits he wants in the cell.
    I’d like the user can write only 5 digits (maximum) for the integer part and
    2 digits for the decimal part.
    Thanks.

    Imported from legacy forums. Posted by Gian Luigi (had 760 views)

    User (Old forums)
    Member
    Post count: 23064

    Perhaps you could try the GridMaskedTextBox as editor. I haven’t tried it yet, but I think it was made for this kind of situation.

    Imported from legacy forums. Posted by Tommy (had 198 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for your answer.
    I already tried the masked edit, but i don’t like it because the user must move the cursor after the decimal point in order to enter the decimal part of the number.
    I’d like that if the user have to enter the value 1.23 , he can press “1” then “.” then “2” and “3”
    With the Masked edit he can’t do this.

    Thanks

    Imported from legacy forums. Posted by Gian Luigi (had 182 views)

    User (Old forums)
    Member
    Post count: 23064

    From the documentation of GridNumericTextBox, I can see it has a property <b>Decimals</b> which you can set to the maximum number of digits that can be entered after the decimal point. I don’t really see such a property to limit the integral part.

    Imported from legacy forums. Posted by Tommy (had 138 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Tom.
    I already try this also.
    But the Decimals property don’t limit the number of digits the user can enter.
    If I set Decimals to 3 the user can enter for example 12,123456 but when he leaves the cell, the value is deleted because invalid.

    Do you know if there is some event that i can trap every time the text of the cell is changed?
    I try with ValueChanged but it is raised only when the cell loose the focus.
    I try KeyDown and KeyPress but they are raised only the first time, when I start to write into the cell, but while editing the cell they are no more raised.

    Thanks again.

    Imported from legacy forums. Posted by Gian Luigi (had 307 views)

    User (Old forums)
    Member
    Post count: 23064

    You could try catching the KeyDown event of the editor, instead of on the cell.

    Imported from legacy forums. Posted by Tommy (had 4827 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.