DataGridView column type C #

0

I have a DataGrid with a DataGridViewComboBoxColumn column, but I want to pass it to the DataGridViewTextBoxColumn column type, so I do the following

if (miDataTable.Rows.Count > 0);
                {
                    // elimina la columna de un data grid
                    dgvCitas.Columns.Remove("pCita");

                    // crea una columna 
                    var column = new DataGridViewTextBoxColumn();
                    column.Name = "pCita";
                    column.HeaderText = "Cita #1";

                    //agrega una columna al data grid
                    dgvCitas.Columns.Insert(2, column);

                }

The problem is that this code is within a cycle and every time I delete the column and I create a new one deleting the same data as I may have, so I take care to help me do something similar to this (It should be mentioned that the following code does not work, syntax error) .

if (miDataTable.Rows.Count > 0 && dgvCitas.Columns[numCita].ValueType.ToString()="DataGridViewComboBoxColumn") ;
                {
\ mi codigo
}

That is to say, I take care that they help me to compare the type of column that it is, because if it is of texbox type it should not enter the if

    
asked by Magdiel Hernandez 19.11.2018 в 17:12
source

1 answer

0

This answers my question, I hope someone is useful to you.

That compares if a datagrid column is a ComboBox type.

if (dgvCitas.Columns[numCita].GetType().ToString() == "System.Windows.Forms.DataGridViewComboBoxColumn")
    {
        \ nuestro codigo
    }
    
answered by 21.11.2018 в 08:49