1

Tables dt like this:

index StartDate         EndDate
1   2015/03/23 22:00    2015/03/23 23:00
2   2015/03/23 22:00    2015/03/23 22:00
3   2015/03/23 22:00    2015/03/23 22:00

I have set:

lookupedit1.Properties.ValueMember = "StartDate";
lookupedit1.Properties.DisplayMember = "StartDate";

So, the value has show OK, long date Type, but i want the DisplayMemeber like short date type. I have try any of below, but it's havn't work expectly.

lookupedit1.Properties.Mask.EditMask = "yyyy-MM-dd";
lookupedit1.Properties.DisplayFormat.FormatString = "yyyy-MM-dd";
lookupedit1.Properties.EditFormat.FormatString = "yyyy-MM-dd";  

How can i resolve my questions?

Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34
Liyu Ge
  • 11
  • 6

1 Answers1

2

i want the DisplayMemeber like short date type

You can use the standard d display-format string for short date (culture specific, described in the Standard Date and Time Format Strings document in MSDN.). To specify formatting-behavior you should add the specific column into the LookUp edit:

lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo()
        {
            FieldName = "StartDate",
            FormatType = DevExpress.Utils.FormatType.DateTime,
            FormatString = "d" // short date
        });
lookUpEdit1.Properties.DataSource = new List<Order> { 
    new Order(){ StartDate = new DateTime(2015, 03, 23, 23, 0, 0) },
    new Order(){ StartDate = new DateTime(2015, 03, 24, 23, 0, 0) },
    new Order(){ StartDate = new DateTime(2015, 03, 25, 23, 0, 0) },
};

To setup display-behavior while editing you can use the editor's Mask :

lookUpEdit1.Properties.Mask.EditMask = "d"; // short date
lookUpEdit1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
lookUpEdit1.Properties.Mask.UseMaskAsDisplayFormat = true;
DmitryG
  • 17,677
  • 1
  • 30
  • 53
  • yeah , i have validate your answer. and it's work OK. `Mask.EditMask = ... ;` `Mask.MaskType = ...;` `Mask.UseMaskAsDisPisplayFormat = ...;` thank you. – Liyu Ge Mar 24 '16 at 01:01