Пример #1
0
        // This changes the type
        public void ChangeType(int typeindex)
        {
            // Can't do this for a fixed field!
            if (isfixed)
            {
                throw new InvalidOperationException();
            }

            // Different?
            if (typeindex != fieldtype.Index)
            {
                // Change field type!
                TypeHandlerAttribute attrib = General.Types.GetAttribute(typeindex);
                fieldtype           = General.Types.GetFieldHandler(typeindex, this.Cells[2].Value);
                this.Cells[1].Value = fieldtype.GetDisplayType();
            }
        }
Пример #2
0
        // This is called when a cell is edited
        public void CellChanged()
        {
            // This gdmn grid thing returns the chosen value as string instead
            // of the object type I added to the combobox...
            if (this.Cells[1].Value is string)
            {
                // Find the TypeHandlerAttribute with this name
                TypeHandlerAttribute attrib = General.Types.GetNamedAttribute(this.Cells[1].Value.ToString());

                // Different?
                if (attrib.Index != fieldtype.Index)
                {
                    // Change field type!
                    this.ChangeType(attrib.Index);
                }
            }

            // Anything in the box?
            if ((this.Cells[2].Value != null) && (this.Cells[2].Value.ToString().Length > 0))
            {
                // Validate value
                fieldtype.SetValue(this.Cells[2].Value);
                this.Cells[2].Value = fieldtype.GetStringValue();

                // This is a fixed field?
                if (rowtype == FieldsEditorRowType.FIXED)
                {
                    // Does this match the default setting?
                    if (fieldtype.GetValue().Equals(fieldinfo.Default))
                    {
                        // Undefine this field!
                        Undefine();
                    }
                }
            }
        }