c# - DateTime format with milliseconds for DevExpress control EditMask property -


i need display date , time using devexpress dateedit control. can achieved setting mask dateedit control. so, have taken datetime pattern current thread ui culture , set devexpress dateedit controls editmask property.

the problem here is, need show milliseconds user. existing cultures not have milliseconds in datetime pattern. so, need add milliseconds field("fff") datetime pattern of selected culture , set dateedit controls editmask property.

my current code block shown below,

var dateedit = new dateedit(); dateedit.properties.vistadisplaymode = devexpress.utils.defaultboolean.true; dateedit.properties.vistaedittime = devexpress.utils.defaultboolean.true; cultureinfo currentuiculture = thread.currentthread.currentuiculture; string editmask = currentuiculture.datetimeformat.generallongtimepattern; dateedit.properties.editmask = editmask; 

below datetime pattern of cultures , expected pattern,

culture     datetime pattern          expected datetime pattern   ---------------------------------------------------------------- {en-us}     "m/d/yyyy h:mm:ss tt"     "m/d/yyyy h:mm:ss.fff tt"          {th-th}     "d/m/yyyy h:mm:ss"        "d/m/yyyy h:mm:ss.fff"   {sv-se}     "yyyy-mm-dd hh:mm:ss"     "yyyy-mm-dd hh:mm:ss.fff" 

how can achieve this?

try out :

// append millisecond pattern current culture's full date time pattern  string fullpattern = datetimeformatinfo.currentinfo.fulldatetimepattern; fullpattern = regex.replace(fullpattern, "(:ss|:s)", "$1.fff"); 

source : msdn


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -