Devexpress xtragrid column set mask with repositoryItemTextEdit
I'm using devexpress 11.1.4. version also xtraGrid control, my code is vb.net I have set repositoryItemTextEdit to display mask into grid column. I whant to set date format:
"dd.mm.yyyy "
At the time of typing looks good , however when cells lose focus it changes in format: "mm.dd.yyyy"
Also sometimes they just emptied or when i choose for example: 10.05.2015. it change the value that it looks like this: 01.05.2015.
I do not know why
Here is my code:
Public dateWithTextEdit As RepositoryItemTextEdit = New RepositoryItemTextEdit
dateWithTextEdit .Mask.UseMaskAsDisplayFormat = True
dateWithTextEdit .Mask.AutoComplete = XtraEditors.Mask.AutoCompleteType.Strong
dateWithTextEdit .Mask.MaskType = XtraEditors.Mask.MaskType.DateTime
dateWithTextEdit .Mask.EditMask = "dd.mm.yyyy"
DGV.RepositoryItems.Add(dateWithTextEdit )
DGV.DataSource = dataTable
With dgvVIEW
.OptionsBehavior.AllowAddRows = DefaultBoolean.True
.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Top
.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.True
.Columns(0).Name = "PROMDDOK"
.Columns(0).FieldName = "PROMDDOK"
.Columns(0).Caption = "DATUM DOKUMENTA"
.Columns(0).ColumnEdit = dateWithTextEdit
.Columns(0).Visible = True
.Columns(0).Width = 120
End With
Problem no. 1.: your edit mask is dd.mm.yyyy
. mm
stands for minutes, you have to use dd.MM.yyyy
.
If this doesn't help, set the column's display format as well. Code in C#:
columns[0].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
columns[0].DisplayFormat.FormatString = "dd.MM.yyyy";
根据DevExpress联机文档,RepositoryItemTextEdit.Mask Property用于在编辑模式下格式化单元格值。要在显示模式下格式化单元格值,请使用格式化单元格值文档中描述的解决方案。
链接地址: http://www.djcxy.com/p/31088.html