示例#1
0
 public ColumnDataDescriptor(string HeaderText, DataColumn Column, ColumnEditorMode Mode = ColumnEditorMode.Auto,
                             EditorDataStyle?Style = null, float?FillWeight   = null, object NullValue     = null, bool IsReadOnly = false,
                             object DataSource     = null, string ValueMember = null, string DisplayMember = null,
                             GetListBoxItemsDelegate GetListBoxItemsMethod = null,
                             FormatValueDelegate FormatValueMethod         = null)
 {
     if (Mode == ColumnEditorMode.Auto)
     {
         if (DataSource != null && ValueMember != null && DisplayMember != null && GetListBoxItemsMethod != null)
         {
             Mode = ColumnEditorMode.ListBox;
         }
         else if (ValueMember != null && GetListBoxItemsMethod != null && FormatValueMethod != null)
         {
             Mode = ColumnEditorMode.ListBox;
         }
         else if (DataSource != null && ValueMember != null && DisplayMember != null)
         {
             Mode = ColumnEditorMode.ComboBox;
         }
         else if (FormatValueMethod != null)
         {
             Mode = ColumnEditorMode.TextBox; this.IsReadOnly = true;
         }
         else if (Column.DataType == typeof(bool))
         {
             Mode = ColumnEditorMode.CheckBox;
         }
         else if (Column.DataType == typeof(Guid))
         {
             Mode = ColumnEditorMode.TextBox; this.IsReadOnly = true;
         }
         else
         {
             Mode = ColumnEditorMode.TextBox;
         }
     }
     this.HeaderText = HeaderText; // Column.Caption;
     this.ColumnName = Column.ColumnName;
     this.Mode       = Mode;
     this.Style      = Style;
     this.IsNull     = Column.AllowDBNull;
     this.NullValue  = NullValue;
     this.IsReadOnly = this.IsReadOnly || Column.ReadOnly || IsReadOnly;
     if (Column.MaxLength > 0)
     {
         this.MaxLength = Column.MaxLength;
     }
     this.FillWeight            = FillWeight;
     this.DataSource            = DataSource;
     this.ValueMember           = ValueMember;
     this.DisplayMember         = DisplayMember;
     this.GetListBoxItemsMethod = GetListBoxItemsMethod;
     this.FormatValueMethod     = FormatValueMethod;
 }
示例#2
0
 public FieldDataDescriptor(string CaptionText, DataColumn Column, FieldEditorMode Mode = FieldEditorMode.Auto,
                            EditorDataStyle?Style = null, int?SizeWidth      = null, object NullValue = null, bool IsReadOnly = false,
                            decimal?Minimum       = null, decimal?Maximum    = null,
                            object DataSource     = null, string ValueMember = null, string DisplayMember = null,
                            GetListBoxItemsDelegate GetListBoxItemsMethod = null, FormatValueDelegate FormatValueMethod = null)
 {
     if (Mode == FieldEditorMode.Auto)
     {
         if (DataSource != null && ValueMember != null && DisplayMember != null && GetListBoxItemsMethod != null)
         {
             Mode = FieldEditorMode.ListBox;
         }
         else if (DataSource != null && ValueMember != null && DisplayMember != null)
         {
             Mode = FieldEditorMode.ComboBox;
         }
         else if (DataSource != null)
         {
             Mode = FieldEditorMode.ComboTextBox;
         }
         else if (FormatValueMethod != null)
         {
             Mode = FieldEditorMode.TextBox; this.IsReadOnly = true;
         }
         else if (Column.DataType == typeof(bool))
         {
             Mode = FieldEditorMode.CheckBox;
         }
         else if (Column.DataType == typeof(byte))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = byte.MinValue; this.Maximum = byte.MaxValue;
         }
         else if (Column.DataType == typeof(short))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = short.MinValue; this.Maximum = short.MaxValue;
         }
         else if (Column.DataType == typeof(int))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = int.MinValue; this.Maximum = int.MaxValue;
         }
         else if (Column.DataType == typeof(long))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = long.MinValue; this.Maximum = long.MaxValue;
         }
         else if (Column.DataType == typeof(ushort))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = ushort.MinValue; this.Maximum = ushort.MaxValue;
         }
         else if (Column.DataType == typeof(uint))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = uint.MinValue; this.Maximum = uint.MaxValue;
         }
         else if (Column.DataType == typeof(ulong))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = ulong.MinValue; this.Maximum = ulong.MaxValue;
         }
         else if (Column.DataType == typeof(DateTime))
         {
             Mode = FieldEditorMode.DateTimeTextBox;
         }
         else if (Column.DataType == typeof(Guid))
         {
             Mode = FieldEditorMode.TextBox; this.IsReadOnly = true;
         }
         else if (Column.MaxLength > 260)
         {
             Mode = FieldEditorMode.MultilineTextBox;
         }
         else
         {
             Mode = FieldEditorMode.TextBox;
         }
     }
     if (Mode == FieldEditorMode.BitMask && (Column.DataType == typeof(long) || Column.DataType == typeof(ulong)))
     {
         Mode = FieldEditorMode.BitMask64;
     }
     this.CaptionText = CaptionText; // Column.Caption;
     this.ColumnName  = Column.ColumnName;
     this.Mode        = Mode;
     this.Style       = Style;
     this.IsNull      = Column.AllowDBNull || Mode == FieldEditorMode.GuidEditor;
     this.NullValue   = NullValue;
     this.IsReadOnly  = this.IsReadOnly || Column.ReadOnly || IsReadOnly || Mode == FieldEditorMode.GuidEditor;
     if (this.IsReadOnly && this.Mode == FieldEditorMode.NumberTextBox)
     {
         this.Mode = FieldEditorMode.TextBox;
     }
     if (Column.MaxLength > 0)
     {
         this.MaxLength = Column.MaxLength;
     }
     if (Minimum.HasValue)
     {
         this.Minimum = Minimum;
     }
     if (Maximum.HasValue)
     {
         this.Maximum = Maximum;
     }
     this.SizeWidth             = SizeWidth;
     this.DataSource            = DataSource;
     this.ValueMember           = ValueMember;
     this.DisplayMember         = DisplayMember;
     this.GetListBoxItemsMethod = GetListBoxItemsMethod;
     this.FormatValueMethod     = FormatValueMethod;
 }