Click here to Skip to main content
15,903,831 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to change DataGridView textbox column to DataGridView ComboBox column in c#

i tried following code but not working


C#
private void dgv1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            e.Control.ContextMenu = new ContextMenu();
            if ((dgv1.CurrentCell.ColumnIndex == 2))
            {
                DataGridViewComboBoxCell cc = new DataGridViewComboBoxCell();

                cc.Items.AddRange(new string[] { "A/C Room", "Non A/C Room", "A/C Dormitory", "Non A/C Dormitory" });
            }
        }



but this not working, Can any one plz help me??
Posted

Hi. I managed to do something like this.
First I tried with CellBeginEdit and CellEndEdit but the ComboBox control didn't appear (just it's editable box). Then I used CellClick and CellValidating. It worked, but I had to solve the "reentrant call" problem - finally I find the solution on the net.
I explained it here: Dynamically change DataGridViewTextBoxCell to DataGridViewComboBoxCell
P.S.
If you manage to use CellBeginEdit and CellEndEdit, please post the solution here - I'm very curious about it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900