Mask for a single cell in datagrid

from:

http://www1.devexpress.com/Support/Center/p/Q130467.aspx

hi,
I am using a datagrid to display values. I have given mask as numeric and edit Mask and UseMaskAsDisplay properties as shown below:

dtvFilteredData.Columns[ "Movement %" ].ColumnEdit = new DevExpress.XtraEditors.Repository. RepositoryItemTextEdit ();

((DevExpress.XtraEditors.Repository. RepositoryItemTextEdit )dtvFilteredData.Columns[ "Movement %" ].ColumnEdit).Mask.MaskType = DevExpress.XtraEditors.Mask. MaskType .Numeric;

((DevExpress.XtraEditors.Repository. RepositoryItemTextEdit )dtvFilteredData.Columns[ "Movement %" ].ColumnEdit).Mask.EditMask = "#,##,##,##,##,##,##,##,##,##,##,##,##,##0.00" ;

((DevExpress.XtraEditors.Repository. RepositoryItemTextEdit )dtvFilteredData.Columns[ "Movement %" ].ColumnEdit).Mask.UseMaskAsDisplayFormat = true ;

But after displaying the values, when i click a particular cell, i want to edit its value. But at this time, the value in that particular cell (And not entire column)must show 6 decuimal places instead of 2 as indicated in the mask. So is it possible to give multiple masks for that column- one for normal mode and one when editing the cell value?

Waiting for your answer..its really urgent...

Thanks,
Regards,
Abi

----------------------------------------------

Hello Abi,

Yes, it's possible to accomplish your task using the GridView.ShownEditor event, for example:

[C#]

private void gridView1_ShownEditor(object sender, EventArgs e)
        {
            GridView view = sender as GridView;
            if (view.FocusedColumn.FieldName == "Movement %")
            {
                DevExpress.XtraEditors.TextEdit edit = (view.ActiveEditor as
DevExpress.XtraEditors.TextEdit);
                edit.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                edit.Properties.Mask.EditMask = "n6";
            }
        }

Thank you,
Paul

 

你可能感兴趣的:(datagrid)