private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { EmbeddableEditorBase editor = null; DefaultEditorOwnerSettings editorSettings = null; editorSettings = new DefaultEditorOwnerSettings( ); editorSettings.DataType = typeof(int); editor = new EditorWithMask(new DefaultEditorOwner(editorSettings)); editorSettings.MaskInput = "nnnn"; e.Row.Cells["cnvcFree"].Editor = editor; }
public void AddRadioButtonColumn(string columnName, string caption, ValueList valueList) { if (valueList != null) { DefaultEditorOwnerSettings editorSettings = new DefaultEditorOwnerSettings( ); editorSettings.DataType = typeof(bool); editorSettings.ValueList = valueList; this.UltraWinGrid.DisplayLayout.Bands[0].Columns[columnName].Editor = new OptionSetEditor(new DefaultEditorOwner(editorSettings)); } this.UltraWinGrid.DisplayLayout.Bands[0].Columns[columnName].Width = 100; this.UltraWinGrid.DisplayLayout.Bands[0].Columns[columnName].Header.Caption = caption; }
public void AddCheckColumn(string columnName, string caption) { DefaultEditorOwnerSettings editorSettings = new DefaultEditorOwnerSettings( ); editorSettings.DataType = typeof(System.Boolean); CheckEditor checkEditor = new CheckEditor(new DefaultEditorOwner(editorSettings)); this.UltraWinGrid.DisplayLayout.Bands[0].Columns[columnName].Editor = checkEditor; this.UltraWinGrid.DisplayLayout.Bands[0].Columns[columnName].Width = 20; this.UltraWinGrid.DisplayLayout.Bands[0].Columns[columnName].Header.Caption = caption; // this.UltraWinGrid.DisplayLayout.Bands[0].Columns[ columnName].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; // this.UltraWinGrid.DisplayLayout.Bands[0].Columns[ columnName].MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth; // this.UltraWinGrid.DisplayLayout.Bands[0].Columns[ columnName].MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals; }
// Format numeric grid cells public static void FormatNumericDp( UltraGridCell cell, int decimalPlaces) { //Set mask editor for muti cell precision on numbers string strMask = ("nnnnnn" + (decimalPlaces > 0 ? "." : "")); strMask = strMask.PadRight ( (decimalPlaces + strMask.Length), Convert.ToChar("n")); var osSettings = new DefaultEditorOwnerSettings { MaskInput = strMask }; var deOwner = new DefaultEditorOwner(osSettings); var meEditor = new EditorWithMask(deOwner); cell.Editor = meEditor; }
// Format numeric grid cells public static void FormatNumericDp ( UltraGridCell cell, int decimalPlaces) { //Set mask editor for muti cell precision on numbers string strMask = ("nnnnnn" + (decimalPlaces > 0 ? "." : "")); strMask = strMask.PadRight ( (decimalPlaces + strMask.Length), Convert.ToChar("n")); var osSettings = new DefaultEditorOwnerSettings { MaskInput = strMask }; var deOwner = new DefaultEditorOwner(osSettings); var meEditor = new EditorWithMask(deOwner); cell.Editor = meEditor; }
/// <summary> /// 获得表格单元所使用的内嵌编辑器 /// </summary> /// <param name="editorType"></param> /// <param name="tag"></param> /// <returns></returns> EmbeddableEditorBase GetEmbeddableEditor(string editorType, object tag) { EmbeddableEditorBase editor = null; DefaultEditorOwnerSettings editorSettings = new DefaultEditorOwnerSettings(); switch (editorType) { default: case "String": case "Text": editorSettings.DataType = typeof(string); return(new EditorWithText(new DefaultEditorOwner(editorSettings))); case "Color": editorSettings.DataType = typeof(Color); return(new ColorPickerEditor(new DefaultEditorOwner(editorSettings))); case "Font": ValueList valueList = new ValueList(); editorSettings.DataType = typeof(string); for (int i = 0; i < System.Drawing.FontFamily.Families.Length; i++) { valueList.ValueListItems.Add(System.Drawing.FontFamily.Families[i].Name); } editorSettings.ValueList = valueList; return(new FontNameEditor(new DefaultEditorOwner(editorSettings))); case "Int": editorSettings.DataType = typeof(int); editor = new EditorWithMask(new DefaultEditorOwner(editorSettings)); editorSettings.MaskInput = "-nnnnnnnn"; return(editor); case "Progress": editorSettings.DataType = typeof(int); return(new Infragistics.Win.UltraWinProgressBar.ProgressBarEditor(new DefaultEditorOwner(editorSettings))); case "Date": editorSettings.DataType = typeof(DateTime); editorSettings.MaskInput = "yyyy-mm-dd"; return(new DateTimeEditor(new DefaultEditorOwner(editorSettings))); case "Time": editorSettings.DataType = typeof(DateTime); editorSettings.MaskInput = "hh:mm:ss"; return(new EditorWithMask(new DefaultEditorOwner(editorSettings))); case "DateTime": editorSettings.DataType = typeof(DateTime); editorSettings.MaskInput = "yyyy-mm-dd hh:mm:ss"; return(new DateTimeEditor(new DefaultEditorOwner(editorSettings))); case "Double": case "Float": editorSettings.DataType = typeof(double); editorSettings.MaskInput = "-nnnnnnnn.nnn"; return(new EditorWithMask(new DefaultEditorOwner(editorSettings))); case "IP": editorSettings.DataType = typeof(string); editor = new EditorWithMask(new DefaultEditorOwner(editorSettings)); editorSettings.MaskInput = "nnn\\.nnn\\.nnn\\.nnn"; return(editor); case "YesNoDropDown": editorSettings.DataType = typeof(bool); valueList = new ValueList(); valueList.ValueListItems.Add(true, "是"); valueList.ValueListItems.Add(false, "否"); editorSettings.ValueList = valueList; return(new EditorWithCombo(new DefaultEditorOwner(editorSettings))); case "YesNoCheckBox": editorSettings.DataType = typeof(bool); return(new CheckEditor(new DefaultEditorOwner(editorSettings))); case "Enum": case "CustomEnum": List <string> slist = tag as List <string>; ValueList vlist = new ValueList(); if (slist != null) { foreach (string str in slist) { vlist.ValueListItems.Add(str); } } editorSettings.ValueList = vlist; editorSettings.DataType = typeof(string); editor = new EditorWithCombo(new DefaultEditorOwner(editorSettings)); return(editor); } }