This is a migrated thread and some comments may be shown as answers.

Mask For Integer in GridViewMaskedTextBoxColumn

4 Answers 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 02 Nov 2011, 05:11 PM
Hi,

I'm trying to use the "GridViewMaskedTextBoxColumn" column in a DataGridView and using the following: -

((

 

GridViewMaskedTextBoxColumn)dataColumn).Mask = "######";

 

((

 

GridViewMaskedTextBoxColumn)dataColumn).MaskType = MaskType.Numeric;

 


I'm expecting this to be a 6-digit numerical input but it isn't working as expected...
This is restricting the input to 1 character ?

What are the correct settings for a numerical "Integer only" (no decimals) input mask for this column type ?

Many Thanks - Paul

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 02 Nov 2011, 05:54 PM
Hi Paul,

In edit mode every field of the GridViewMaskedTextBoxColumn will be represented by a MaskedTextBox control. Therefore, for a numeric with 6 digits you should use the "d6" mask, as it is explained in this help article.

Is this what do you need?

Kind regards,

Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Paul
Top achievements
Rank 1
answered on 10 Nov 2011, 05:35 PM
Hi

I'm still having major issues with this.

There is insufficient control over the MaskedTextBox control that is used.

What is the correct Mask and MaskType to provide a 6.2 decimal number ? (123456.78)
I'm tearing my hair out with this at the moment. I've tried all kinds of different combinations.

We can get a 6-digit integer using "######" but we also have an ugly Placeholder of "_" in the control. We would prefer an empty space, or even to be abl to disable it completely. We cant right-align the input either.

I have tried inheriting from "GridViewBoundColumnBase" and drawing my own control as per a post I found. This would be great except that we get all kinds of crazy tab-issues with the keyboard and the cell gets updated after a single key-stroke and loses input focus. Designing a custom column is a mine-field really.

I'm sorry for the question, but its incredibly difficult to get what we need.
How difficult can it be to provide a decimal column with configurations for pre-decimal digits and post-decimal digits ?

Please help.
0
Paul
Top achievements
Rank 1
answered on 11 Nov 2011, 09:24 AM
OK,

:-) I finally got the column formatting sorted

BUT

How can I get the "GridViewMaskedTextBoxColumn" column to be right-aligned when in edit mode for the cell. ?
0
Dimitrina
Telerik team
answered on 11 Nov 2011, 12:22 PM
Hello Paul,

 This is good!

 The GridViewMaskedTextBoxColumn uses a RadMaskedTextBox for the EditTemplate of the cells. As the wrong TextAlignment is a problem with the RadMaskedTextBox, you will need to use another editor for the editing.

If you want the EditTemplate of the GridViewCell to be Right aligned, you may set the CellEditTemplate to be a DataTemplate with:
1.  TextBox and set TextAlignment="Right" for it.
2.  RadMaskedTextBox and set HorizontalContentAlignment="Right" for it.
3. Use another numeric editor.

I hope that this is helpful. 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Paul
Top achievements
Rank 1
Share this question
or