Ejemplo n.º 1
0
        void PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
        {
            TableColumn c = e.Row.DataContext as TableColumn;

            if (e.Column.DisplayIndex == 2)
            {
                if (TableDataType.IsLengthFixed(c.DataType))
                {
                    TextBox textBox = (e.EditingElement as TextBox);
                    textBox.IsReadOnly = true;
                }
                else
                {
                    TextBox textBox = (e.EditingElement as TextBox);
                    textBox.IsReadOnly = false;
                }
            }
            if (e.Column.DisplayIndex == 3)
            {
                if (TableDataType.IsNullFixed(c.DataType))
                {
                    CheckBox checkBox = (e.EditingElement as CheckBox);
                    checkBox.IsEnabled = false;
                    checkBox.IsChecked = false;
                }
                else
                {
                    CheckBox checkBox = (e.EditingElement as CheckBox);
                    checkBox.IsEnabled = true;
                    checkBox.IsChecked = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
        {
            var c = e.Row.DataContext as TableColumn;

            if (e.Column.DisplayIndex == 2)
            {
                if (c != null && TableDataType.IsLengthFixed(c.DataType))
                {
                    var textBox = (e.EditingElement as TextBox);
                    if (textBox != null)
                    {
                        textBox.IsReadOnly = true;
                    }
                }
                else
                {
                    var textBox = (e.EditingElement as TextBox);
                    if (textBox != null)
                    {
                        textBox.IsReadOnly = false;
                    }
                }
            }
            if (e.Column.DisplayIndex != 3)
            {
                return;
            }
            if (c != null && TableDataType.IsNullFixed(c.DataType))
            {
                var checkBox = (e.EditingElement as CheckBox);
                if (checkBox != null)
                {
                    checkBox.IsEnabled = false;
                    checkBox.IsChecked = false;
                }
            }
            else
            {
                var checkBox = (e.EditingElement as CheckBox);
                if (checkBox != null)
                {
                    checkBox.IsEnabled = true;
                    checkBox.IsChecked = false;
                }
            }
        }