hi there,

i have a question in datagridview dropdown boxes. in a datagridview i have 3 datagridview combo boxes, but i combo box i want to make a text box when the user clicks on that datagridview combobox, i did it, but now all the datagridview dropdown boxes become datagridview text boxe when the user clicks it.
how can i avoid this situation,

thanks

Post the code.

Post the code.

private void dgvForm_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            int rowIndex = 0;
            int rowCount = 0;

            

            DataGridViewComboBoxCell cell = dgvForm.CurrentCell as DataGridViewComboBoxCell;

            if (cell != null && !cell.Items.Contains(e.FormattedValue))
            {
                // Insert the new value into position 0
                // in the item collection of the cell
                cell.Items.Insert(0, properStr);
                // When setting the Value of the cell, the  
                // string is not shown until it has been
                // comitted. The code below will make sure 
                // it is committed directly.
                if (dgvForm.IsCurrentCellDirty)
                {
                    // Ensure the inserted value will 
                    // be shown directly.
                    // First tell the DataGridView to commit 
                    // itself using the Commit context...
                    dgvForm.CommitEdit(DataGridViewDataErrorContexts.Commit);
                }
                // ...then set the Value that needs 
                // to be committed in order to be displayed directly.
                cell.Value = cell.Items[0];
            }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.