开发者

DevExpress Winforms Databinding: DisplayFormat Ignored

I'm databinding and formatting a TextEdit control like so:

txtArea.DataBindings.Add("EditValue", _ProductItem, "Area", true, DataSourceUpdateMode.OnPropertyChanged);
txtArea.Properties.Mask.EditMask = @"\d*\.{0,1}\d{1,3}";

And in the properties for this TextEdit textbox, I've set Properties -> Mask -> MaskType to RegEx. And also, Properties -> DisplayFormat -> FormatType is Numeric and the FormatString is set to n3.

If the databound EditValue is set to 24.12345 then that's what is displayed in the textbox when I run the app. But, I'm e开发者_StackOverflow中文版xpecting to just see 24.123. And when I click in the textbox, the value displayed is then changed to 24.123 correctly. But when I exit the textbox (without making any changes), it's set back to the original EditValue of 24.12345.

If I hardcode the EditValue like txtArea.EditValue = 24.12345 the initial display is 24.123 as expected. And while in edit mode, it's 24.123 as expected.

It's like DataBinding is ignoring the DisplayFormat property altogether. Does anyone have any experience with this using DevExpress controls?


Here's the fix:

Set txtArea.Properties.Mask.UseMaskAsDisplayFormat to true.

This worked although I did try it before while playing with all of the various formatting options.


memoEdit.DataBindings.Add("Text", DataSource, "DataMember", false, DataSourceUpdateMode.OnPropertyChanged);

//or

 memoEdit.DataBindings.Add("EditValue", DataSource, "DataMember", false, DataSourceUpdateMode.OnPropertyChanged);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜