示例#1
0
文件: uidto.cs 项目: thevpc/neormf
 public void InstallComponent(Control textBox, DataType dtype)
 {
     if (typeof(StringType).IsAssignableFrom(dtype.GetType()))
     {
         StringType itype = (StringType)dtype;
         int        max   = itype.GetMaxLength();
         if (textBox is TextBox)
         {
             ((TextBox)textBox).MaxLength = max;
             return;
         }
     }
     else if (typeof(IntType).IsAssignableFrom(dtype.GetType()))
     {
         if (textBox is TextBox)
         {
             IntType itype = (IntType)dtype;
             ((TextBox)textBox).MaxLength = (int)Math.Ceiling(Math.Log10(itype.GetMaxValue()));
             textBox.KeyPress            += new KeyPressEventHandler(IntTextBox_KeyPress);
             return;
         }
     }
     else if (typeof(DoubleType).IsAssignableFrom(dtype.GetType()))
     {
         if (textBox is TextBox)
         {
             //DoubleType dbltype=(DoubleType)dtype;
             ((TextBox)textBox).MaxLength = 50;
             textBox.KeyPress            += new KeyPressEventHandler(DoubleTextBox_KeyPress);
             return;
         }
     }
     else if (typeof(DateTimeType).IsAssignableFrom(dtype.GetType()))
     {
         if (textBox is TextBox)
         {
             return;
         }
     }
     else if (typeof(TimeType).IsAssignableFrom(dtype.GetType()))
     {
         if (textBox is TextBox)
         {
             return;
         }
     }
     else if (typeof(BooleanType).IsAssignableFrom(dtype.GetType()))
     {
         if ((textBox is CheckBox) || (textBox is RadioButton))
         {
             return;
         }
     }
     throw new UnsupportedOperationException();
 }
示例#2
0
文件: uidto.cs 项目: thevpc/neormf
 public void InstallComponent(Control textBox, DataType dtype)
 {
     if (typeof(StringType).IsAssignableFrom(dtype.GetType()))
     {
         StringType itype = (StringType)dtype;
         int        max   = itype.GetMaxLength();
         SetControlTextLen(textBox, max);
         return;
     }
     else if (typeof(IntType).IsAssignableFrom(dtype.GetType()))
     {
         IntType itype = (IntType)dtype;
         SetControlTextLen(textBox, (int)Math.Ceiling(Math.Log10(itype.GetMaxValue())));
         return;
     }
     else if (typeof(DoubleType).IsAssignableFrom(dtype.GetType()))
     {
         //DoubleType dbltype=(DoubleType)dtype;
         SetControlTextLen(textBox, 50);
         //textBox.KeyPress+=new KeyPressEventHandler(DoubleTextBox_KeyPress);
         return;
     }
     else if (typeof(DateTimeType).IsAssignableFrom(dtype.GetType()))
     {
         return;
     }
     else if (typeof(TimeType).IsAssignableFrom(dtype.GetType()))
     {
         return;
     }
     else if (typeof(BooleanType).IsAssignableFrom(dtype.GetType()))
     {
         return;
     }
     throw new UnsupportedOperationException();
 }