views:

319

answers:

1

(This question is narrower in scope than this question I asked earlier.)

Say I have a DataGridViewComboBoxColumn, and want to switch the style of the ComboBox control between DropDownList and DropDown (mainly for the text field editing capability). I'd like to do this on a row-by-row basis (at the DataGridViewComboBoxCell level).

How would I do that programatically?

Or maybe a different way of asking: How do I access the ComboBox control given an object of type DataGridViewComboBoxCell?

(I'm in VB 2005.)

Thanks as always.

+1  A: 

Not sure if you still need an answer, but i have a question that covers similar ground: http://stackoverflow.com/questions/1918216/detect-which-column-is-showing-an-editing-control-in-a-datagridview

i use something like this line to get the combobox out of the DataGridView (DGV) in my DataGridView's CellValidating event:

Dim comboBox As DataGridViewComboBoxCell = DGV.Item(e.ColumnIndex, e.RowIndex)

later i use this line to get change the DropDownList ComboBoxCell to a DropDown:

cb.DropDownStyle = ComboBoxStyle.DropDown

For mine to work i had to make sure the 'cb' was of the ComboBox type, i dont remember if i was able to get it working well if the combobox was of the DataGridViewComboBoxCell type.

Jugglingnutcase
Thanks for the answer. I ended up having a column with `DataGridViewComboBoxCell`s and regular `DataGridViewCell`s.
John at CashCommons