Subclassed Devexpress TextEdit not displaying correctly


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 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 (123 views, 6.00 KB)
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ger,

Ger Cannoll (11/17/2011)
this.Properties.Mask.EditMask = "n02";


I believe that the EditMask should be "n2" Also, use the New() constructor instead of the OnEnter.


Edhy Rijo

Edited 13 Years Ago by Edhy Rijo
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
That would be my first reaction as well.  Masking is fairly consistent in .NET.  There are a number of help topics in the standard .NET help about masking and formatting.  3rd party controls generally stick to these standards for the most part.  If you look through this article, string.Format, you will find a lot of link that take you to data type specific formats that will give you a ton of information on the standard formats.  These formats, like Edhy mentions (n2) will ring true. 

There are other options too for optional values, like "0,0.0##". In this format, comma separators will be used and at least 1 decimal place will be forced.  But up to 3 decimal placed will be allowed.  So I would recommend researching some of this as there is a treasure trove of information if you dig deep enough.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 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