Subclassed Devexpress TextEdit not displaying correctly


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have a Subclassed Devexpress TextEdit control, where I want a Numeric Field, displaying 2 decimal points. This does not show the decimal points mask, unless I Click into the control. If the value has zero init , it displays as 0  (Not 0.00). The minute I click into it , or Edit it, it displays correctly. I have tried the same thing with the Devex Control itself dropped on the form, and manually set the Properties (For which I have Code in the Subclass) , and it works fine.

Also, if I set the properties manually on the form in my subclassed control, it also shows the 2 decimals

My subclass code is as follows:

public class dxTextEdit2D : dxTextEdit
{
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
this.Properties.Mask.UseMaskAsDisplayFormat = true;
this.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
this.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
this.Properties.EditFormat.FormatString = "###,####,###,##0.00";
this.Properties.DisplayFormat.FormatString = "###,####,###,##0.00";
this.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
this.Properties.Mask.EditMask = "n02";
}
} // End dxTextEditN2


I have also attached a screen shot of whats happening

 


Attachments
SfDx2decimalsNotShowing.png (171 views, 6.00 KB)
Reply
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Trent, Edhy, thanks for replying.

I think the n02 is ok as it was working when I set focus on the control. I got a reply back from Devexpress who pointed me in the right direction , similar to Edhy's suggestion  as to where to put the Event code, so am now also over-riding the InitializeDefaultProperties event, and its working fine now.

The Control.Enter event occurs when the control becomes focused. If you wish to use the mask by default, I suggest you override the InitializeDefaultProperties method:
protected override void InitializeDefaultProperties()
            {
                base.InitializeDefaultProperties();
                this.Properties.Mask.UseMaskAsDisplayFormat = true;
                this.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                this.Properties.Mask.EditMask = "n02";
            }


 
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search