Exemple #1
0
        // Reverts the text in the control to what is stored in the database object.
        public void Revert()
        {
            reverting = true;
            this.Items.Clear();

            if (DatabaseField == null || DatabaseObject == null)
            {
                Text = "";
                return;
            }

            // if we are using custom choices (most likely the attribute dialog) set the drop down
            // options up
            if (customChoices != null)
            {
                foreach (object currChoice in customChoices)
                {
                    if (currChoice is DBAttrPossibleValues)
                    {
                        this.Items.Add(((DBAttrPossibleValues)currChoice).Value);
                    }
                    else
                    {
                        this.Items.Add(currChoice);
                    }
                }

                if (Items.Contains(DatabaseField.GetValue(DatabaseObject)))
                {
                    SelectedItem = DatabaseField.GetValue(DatabaseObject);
                }
            }

            // if we are representing an enum, set that up, otherwise combo support is not implemented.
            else if (DatabaseField.DBType == DBField.DBDataType.ENUM)
            {
                Enum selectedValue = (Enum)DatabaseField.GetValue(DatabaseObject);
                foreach (object currValue in Enum.GetValues(selectedValue.GetType()))
                {
                    this.Items.Add(currValue);
                }
                this.SelectedItem = selectedValue;
            }

            reverting = false;
        }
Exemple #2
0
        // Reverts the text in the control to what is stored in the database object.
        public void RevertText()
        {
            if (DatabaseField == null || DatabaseObject == null)
            {
                Text = "";
                return;
            }

            if (DatabaseField.GetValue(DatabaseObject) == null)
            {
                Text = "";
            }
            else
            {
                Text = DatabaseField.GetValue(DatabaseObject).ToString();
            }

            UpdateValidationColor();
        }