2013-06-26 175 views
1

我試圖使用下面的代碼格式化Ultragridcell,它工作正常。標準格式化與UltragridCells中的自定義格式化

//代碼

  DefaultEditorOwnerSettings editorSettings; 
      DateTimeEditor datetime_editor; 
      editorSettings = new DefaultEditorOwnerSettings() 
      editorSettings.DataType = typeof(DateTime); 
      editorSettings.MaskInput = "mm/dd/yyyy"; 
      datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings)); 
      e.Row.Cells["DateInfo"].Editor = datetime_editor; 

但是當我嘗試format像下面的代碼,它失敗。

//代碼

  DefaultEditorOwnerSettings editorSettings; 
      DateTimeEditor datetime_editor; 
      editorSettings = new DefaultEditorOwnerSettings() 
      editorSettings.DataType = typeof(DateTime); 
      editorSettings.MaskInput = "D"; 
      datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings)); 
      e.Row.Cells["DateInfo"].Editor = datetime_editor; 

是隻有custom formatting太有限類型的工作原理與細胞或我錯了地方。

需要對此提出建議。

回答

2

看來,你認爲MaskInput財產支持Composite Formatting提供的所有格式化功能,但我不認爲它是真實的。
可供MaskInput 的格式據我所知僅限於這些由UltraGrid Designer提供。

使用UltraGrid Designer(在UltraGrid控件上單擊鼠標右鍵,選擇UltraGrid Designer),單擊Data Schema並定義一個數據模式,其中一列是DateTime列。然後轉到Bands and Column Settings節點,選擇列,然後選擇定義爲DateTime的列。在屬性窗口中,您可以找到MaskInput屬性及其允許的值。您可以嘗試使用預定義的蒙版進行試驗,並檢查是否有符合您要求的蒙版。

正如我所說,這是我認爲是真實的。我不知道是否有另一種高級模式在設計時或運行時設置這些屬性。如果來自Infragistics的某人想要爲此答案添加某些內容,將會受到歡迎

+0

是否有可能從代碼中獲取這些值?以便我可以填充這些以供用戶選擇一個。 – iamCR