-2

IDE: Visual studio c# .net 4.0

In my project I have a datagridview in that I have a comboboxcell, which is having 4 items a,b,c,d in dropdown, and I want to show that dropdown list when user clicks on button1

datagridviewComboboxcell on button_click event.

button_Onclick(sender s, eventargs e)
{
  DataGridViewComboBoxCell dgv = (DataGridViewComboBoxCell)gvTeam2.Rows[0].Cells[4]; 

  dgv.dropdown = true // available in normal combobox
  // not available in datagridview combobox cell.
}
user3410150
  • 61
  • 1
  • 2
  • 8
  • Your question is very unclear, what exactly is your problem? If you are new to our community please read [How to ask](http://stackoverflow.com/questions/how-to-ask) – Karl-Henrik Apr 24 '14 at 06:15
  • What thing you are not getting, I have made it more clear have a look and remove -ve rating. – user3410150 Apr 24 '14 at 06:19
  • So if I understand you correctly you are asking for how to make a custom button show the dropdown menu? The code you have written should do that, could you also post your markup code? – Karl-Henrik Apr 24 '14 at 06:26
  • No it wont do it. He said that there is no dropdown option to the `DataGridViewComboBoxCell` – Georgi Apr 24 '14 at 06:29
  • Yes you are getting my point, but this code not working for datagridviewComboBoxcell, only works for normal combobox. – user3410150 Apr 24 '14 at 06:30
  • You need to use the [editingcontrol property](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.editingcontrol%28v=vs.110%29.aspx) and this [previously asked question](http://stackoverflow.com/questions/241100/how-to-manually-drop-down-a-datagridviewcomboboxcolumn) might help. – Karl-Henrik Apr 24 '14 at 06:41

1 Answers1

1

Try this:

gvTeam2.CurrentCell = gvTeam2[4, 0];
gvTeam2.BeginEdit(false);
gvTeam2.EditingControl as DataGridViewComboBoxEditingControl).DroppedDown = true;
Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
  • Not working, Error-> Cannot resolve symbol .DroppedDown – user3410150 Apr 24 '14 at 07:29
  • I see I've missed the opening bracket on the third row, did you complete it in your code? I've tested it on a demo application and it seems to be working fine for me... – Zohar Peled Apr 24 '14 at 07:40