예제 #1
0
        public override object Clone()
        {
            TrimMaskedTextBoxDataGridViewColumn column = (TrimMaskedTextBoxDataGridViewColumn)base.Clone();

            column.Mask       = mask;
            column.EnumsType  = enumsType;
            column.TrimResult = trim;

            return(column);
        }
예제 #2
0
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            object myvalue;
            TrimMaskedTextBoxDataGridViewColumn dgvc = this.OwningColumn as TrimMaskedTextBoxDataGridViewColumn;

            if (enumsType != typeof(System.DBNull) && value != null && value.GetType() != typeof(System.DBNull) && !string.IsNullOrEmpty(value.ToString()))
            {
                string text = Enum.GetName(enumsType, int.Parse(value.ToString()));
                myvalue = text.Replace('_', ' ');
                if (dgvc.ResourceManager != null)
                {
                    myvalue = dgvc.ResourceManager.GetString(text);
                }
            }
            else
            {
                myvalue = value;
            }
            return(base.GetFormattedValue(myvalue, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
        }
예제 #3
0
        public override void InitializeEditingControl(int rowIndex, object
                                                      initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            TrimMaskedTextBoxDataGridViewControl ctl =
                DataGridView.EditingControl as TrimMaskedTextBoxDataGridViewControl;

            DataGridViewColumn dgvc = this.OwningColumn;

            if (dgvc is TrimMaskedTextBoxDataGridViewColumn)
            {
                TrimMaskedTextBoxDataGridViewColumn rtvc = dgvc as TrimMaskedTextBoxDataGridViewColumn;
                ctl.Mask       = rtvc.Mask;
                ctl.TrimResult = rtvc.TrimResult;
                ctl.PromptChar = ' ';
                ctl.EnumsType  = rtvc.EnumsType;
            }
            ctl.Text = (initialFormattedValue is System.DBNull) ? string.Empty : (string)initialFormattedValue;

            // Set the value of the editing control to the current cell value.
            base.InitializeEditingControl(rowIndex, initialFormattedValue,
                                          dataGridViewCellStyle);
        }