public void SetNullItemClickBase(object sender, DataRow currentRow) { Control sourceControl = ((ContextMenu)((MenuItem)sender).Parent).SourceControl; string controlId = ""; if (sourceControl.Tag != null) { controlId = Conversions.ToString(sourceControl.Tag); } if (sourceControl is DeklaritComboBox) { DeklaritComboBox box = (DeklaritComboBox)sourceControl; if (box.ComboBox.Tag != null) { controlId = Conversions.ToString(box.ComboBox.Tag); box.SelectedIndex = -1; } } if ((controlId.Length == 0) && (sourceControl.Parent != null)) { sourceControl = sourceControl.Parent; controlId = Conversions.ToString(sourceControl.Tag); } this.GetControl(controlId).Focus(); if (sourceControl is TextBox) { TextBox box2 = (TextBox)sourceControl; box2.Text = ""; } if (sourceControl is UltraDateTimeEditor) { UltraDateTimeEditor editor = (UltraDateTimeEditor)sourceControl; editor.Value = RuntimeHelpers.GetObjectValue(Convert.DBNull); } if (sourceControl is UltraTextEditor) { UltraTextEditor editor2 = (UltraTextEditor)sourceControl; editor2.Text = ""; } if (sourceControl is UltraNumericEditor) { UltraNumericEditor editor3 = (UltraNumericEditor)sourceControl; editor3.Value = RuntimeHelpers.GetObjectValue(Convert.DBNull); } if (sourceControl is UltraMaskedEdit) { UltraMaskedEdit edit = (UltraMaskedEdit)sourceControl; edit.Text = ""; } if (sourceControl is LinkUltraLabelPrompt) { LinkUltraLabelPrompt prompt = (LinkUltraLabelPrompt)sourceControl; prompt.UltraLabel.Text = ""; prompt.UltraLabel.Focus(); string descriptionTag = prompt.DescriptionTag; if ((descriptionTag != null) && (descriptionTag.Length != 0)) { currentRow[descriptionTag] = RuntimeHelpers.GetObjectValue(Convert.DBNull); } } currentRow[controlId] = RuntimeHelpers.GetObjectValue(Convert.DBNull); DataColumn column = currentRow.Table.Columns[controlId]; if (((column != null) && (column.ExtendedProperties["TreatEmptyAsNull"] != null)) && (Convert.ToBoolean(column.ExtendedProperties["TreatEmptyAsNull"].ToString()) && !column.DataType.Equals(typeof(DateTime)))) { currentRow[controlId] = RuntimeHelpers.GetObjectValue(FormHelperClass.EmptyValue(column.DataType)); } }
public static void SetReadOnly(Control control, bool readOnlyValue) { if (control is TextBox) { TextBox box = (TextBox)control; box.ReadOnly = readOnlyValue; } if (control is Label) { Label label = (Label)control; label.Enabled = !readOnlyValue; } if (control is UltraDateTimeEditor) { UltraDateTimeEditor editor = (UltraDateTimeEditor)control; editor.Enabled = !readOnlyValue; } if (control is UltraTextEditor) { UltraTextEditor editor2 = (UltraTextEditor)control; editor2.Enabled = !readOnlyValue; } if (control is UltraNumericEditor) { UltraNumericEditor editor3 = (UltraNumericEditor)control; editor3.Enabled = !readOnlyValue; } if (control is UltraMaskedEdit) { UltraMaskedEdit edit = (UltraMaskedEdit)control; edit.Enabled = !readOnlyValue; } if (control is UltraCheckEditor) { UltraCheckEditor editor4 = (UltraCheckEditor)control; editor4.Enabled = !readOnlyValue; } if (control is CheckBox) { CheckBox box2 = (CheckBox)control; box2.Enabled = !readOnlyValue; } if (control is ComboBox) { ComboBox box3 = (ComboBox)control; box3.Enabled = !readOnlyValue; } if (control is Button) { Button button = (Button)control; button.Enabled = !readOnlyValue; } if (control is LinkUltraLabelPrompt) { LinkUltraLabelPrompt prompt = (LinkUltraLabelPrompt)control; prompt.Enabled = !readOnlyValue; } if (typeof(DeklaritComboBox).IsAssignableFrom(control.GetType())) { DeklaritComboBox box4 = (DeklaritComboBox)control; box4.Enabled = !readOnlyValue; } if (typeof(UltraComboEditor).IsAssignableFrom(control.GetType())) { UltraComboEditor editor5 = (UltraComboEditor)control; editor5.Enabled = !readOnlyValue; } }