示例#1
0
        private void CrearColumnasGrillaDetalle()
        {
            this.dgvDataExtensionDetalle.DataGridView.Rows.Clear();
            this.dgvDataExtensionDetalle.DataGridView.Columns.Clear();
            this.dgvDataExtensionDetalle.Mode = Mode.ReadOnly;

            var colummn = new CustomColumnDataGridView
            {
                Name = "Id",
                HeaderText = "Id",
                Width = 100,
                ReadOnly = true,
                Visble = false
            };
            this.dgvDataExtensionDetalle.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "Campo",
                HeaderText = "Campo",
                Width = 200,
                ControlType = CustomControlType.TextBox,
                DataType = DataType.Default
            };
            this.dgvDataExtensionDetalle.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "Tipo",
                HeaderText = "Tipo",
                Width = 100,
                ControlType = CustomControlType.DropDownList
            };
            this.dgvDataExtensionDetalle.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "Tamanio",
                HeaderText = "Tamaño",
                Width = 100,
                ControlType = CustomControlType.TextBox,
                DataType = DataType.Enteros
            };
            this.dgvDataExtensionDetalle.CustomColumns.AddColumn(colummn);

            dgvDataExtensionDetalle.CustomColumns.AddColumn(new DataGridViewCheckBoxColumn());
            dgvDataExtensionDetalle.CustomColumns[(int)TipoColumnaDEDetalle.EsClave].Name = "EsClavePrimaria";
            dgvDataExtensionDetalle.CustomColumns[(int)TipoColumnaDEDetalle.EsClave].HeaderText = "Es Clave";
            dgvDataExtensionDetalle.CustomColumns[(int)TipoColumnaDEDetalle.EsClave].Width = 20;
            dgvDataExtensionDetalle.DataGridView.Columns[(int)TipoColumnaDEDetalle.EsClave].Width = 20;
            dgvDataExtensionDetalle.DataGridView.Columns[(int)TipoColumnaDEDetalle.EsClave].Name = "EsClavePrimaria";
            dgvDataExtensionDetalle.DataGridView.Columns[(int)TipoColumnaDEDetalle.EsClave].HeaderText = "Es Clave";

            dgvDataExtensionDetalle.CustomColumns.AddColumn(new DataGridViewCheckBoxColumn());
            dgvDataExtensionDetalle.CustomColumns[(int)TipoColumnaDEDetalle.EsNulo].Name = "EsNulo";
            dgvDataExtensionDetalle.CustomColumns[(int)TipoColumnaDEDetalle.EsNulo].HeaderText = "Es Nulo";
            dgvDataExtensionDetalle.CustomColumns[(int)TipoColumnaDEDetalle.EsNulo].Width = 20;
            dgvDataExtensionDetalle.DataGridView.Columns[(int)TipoColumnaDEDetalle.EsNulo].Width = 20;
            dgvDataExtensionDetalle.DataGridView.Columns[(int)TipoColumnaDEDetalle.EsNulo].Name = "EsNulo";
            dgvDataExtensionDetalle.DataGridView.Columns[(int)TipoColumnaDEDetalle.EsNulo].HeaderText = "Es Nulo";

            colummn = new CustomColumnDataGridView
            {
                Name = "ValorPorDefecto",
                HeaderText = "Valor Defecto",
                Width = 100,
                ControlType = CustomControlType.TextBox,
                DataType = DataType.Default
            };
            this.dgvDataExtensionDetalle.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "Estado",
                HeaderText = "Estado",
                Width = 100,
                ControlType = CustomControlType.DropDownList
            };
            this.dgvDataExtensionDetalle.CustomColumns.AddColumn(colummn);

            for (int i = 0; i < dgvDataExtensionDetalle.DataGridView.Columns.Count; i++)
            {
                dgvDataExtensionDetalle.DataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
示例#2
0
        /// <summary>
        /// Procesar la Información que contiene la Celda Actual y cargarla en el Control que le corresponde segun el Tipo.
        /// </summary>
        /// <param name="col">Columna Personalizada.</param>
        /// <param name="e">Argumento del evento.</param>
        private void ProcessCellEnter(CustomColumnDataGridView col, DataGridViewCellEventArgs e)
        {
            var cell = customDataGridView.CurrentCell;
            cell.Selected = true;
            switch (col.ControlType)
            {
                case CustomControlType.TextBox:
                    textBox.Text = string.Empty;
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(textBox, cell));
                    }

                    ShowControl(textBox, cell);

                    textBox.DataType = col.DataType;
                    textBox.IsMayusculas = col.UpperCase;
                    textBox.Text = cell.Value == null ? string.Empty : cell.Value.ToString();
                    textBox.SelectAll();
                    break;
                case CustomControlType.DropDownList:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(comboBox, cell));
                    }

                    ShowControl(comboBox, cell);
                    if (cell.Tag == null) comboBox.SelectedIndex = -1;
                    else comboBox.SelectedValue = cell.Tag;
                    break;
                case CustomControlType.ComboSimple:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(comboSimple, cell));
                    }

                    ShowControl(comboSimple, cell);
                    if (cell.Tag == null) comboSimple.SelectedIndex = -1;
                    else comboSimple.SelectedValue = cell.Tag;
                    break;
                case CustomControlType.FindDropDownList:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(findComboBox, cell));
                    }

                    ShowControl(findComboBox, cell);
                    if (cell.Tag == null) findComboBox.SelectedIndex = -1;
                    else findComboBox.SelectedValue = cell.Tag;
                    findComboBox.Text = cell.Value == null ? string.Empty : cell.Value.ToString();
                    break;
                case CustomControlType.GridComboBox :
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(comboBoxGrid, cell));
                    }

                    ShowControl(comboBoxGrid, cell);
                    if (cell.Tag == null) comboBoxGrid.SelectedIndex = -1;
                    else comboBoxGrid.ValueReturned = cell.Tag;
                    comboBoxGrid.Text = cell.Value == null ? string.Empty : cell.Value.ToString();
                    break;
                case CustomControlType.CheckBox:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(checkBox, cell));
                    }

                    ShowControl(checkBox, cell);
                    checkBox.Checked = cell.Value == null ? false : Convert.ToBoolean(cell.Value);
                    break;
                case CustomControlType.MaskedTextBox:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(maskedEdit, cell));
                    }

                    ShowControl(maskedEdit, cell);
                    maskedEdit.Mask = col.Mask;
                    maskedEdit.Text = cell.Value == null ? string.Empty : cell.Value.ToString();
                    break;
                case CustomControlType.DateTimePicker:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(dateTimePicker, cell));
                    }

                    ShowControl(dateTimePicker, cell);
                    dateTimePicker.Value = cell.Value == null ? DateTime.Now : Convert.ToDateTime(cell.Value);
                    break;
                case CustomControlType.MultiColumnComboBox:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(multiColumnComboBox, cell));
                    }

                    ShowControl(multiColumnComboBox, cell);
                    if (cell.Tag == null) multiColumnComboBox.SelectedIndex = -1;
                    else multiColumnComboBox.SelectedValue = cell.Tag;
                    break;
                case CustomControlType.ComboForm:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(comboForm, cell));
                    }
                    ShowControl(comboForm, cell);
                    comboForm.Data = cell.Tag;
                    comboForm.Text = cell.Value == null ? string.Empty : cell.Value.ToString();
                    break;
                case CustomControlType.Boton:
                    if (BeforeShowControl != null)
                    {
                        BeforeShowControl(this, new BeforeShowControlEventArg(boton, cell));
                    }

                    ShowControl(boton, cell);
                    break;

                default:
                    break;
            }
        }
        private void CrearColumnasDataExtension()
        {
            dgvDataExtension.DataGridView.Rows.Clear();
            dgvDataExtension.DataGridView.Columns.Clear();
            dgvDataExtension.Mode = Mode.ReadOnly;

            var colummn = new CustomColumnDataGridView
            {
                Name = "Nombre",
                HeaderText = "Nombre",
                ReadOnly = true,
                Width = 300
            };
            dgvDataExtension.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "Descripcion",
                HeaderText = "Descripción",
                ReadOnly = true,
                Width = 400
            };
            dgvDataExtension.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "EsUsadaComoBase",
                HeaderText = "Es Base",
                ReadOnly = true,
                Width = 100
            };
            dgvDataExtension.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "NombreBaseFuente",
                HeaderText = "Nombre Base",
                ReadOnly = true,
                Width = 300
            };
            dgvDataExtension.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "NombreBaseMostrar",
                HeaderText = "Nombre Base Mostrar",
                ReadOnly = true,
                Width = 300
            };
            dgvDataExtension.CustomColumns.AddColumn(colummn);

            colummn = new CustomColumnDataGridView
            {
                Name = "Estado",
                HeaderText = "Estado",
                ReadOnly = true,
                Width = 100
            };
            dgvDataExtension.CustomColumns.AddColumn(colummn);

            for (int i = 0; i < dgvDataExtension.DataGridView.Columns.Count; i++)
            {
                dgvDataExtension.DataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }