combobox in datagridview not working properly - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

combobox in datagridview not working properly

Hi,

I have one main form , on button click of this form I am starting backgound worker, in doWork event of it , it opens other sub form which has datagridview, datagridview contains two datagridtextbox column and one datagridCombobox column, but if I clicks on any combo box in datagridview then it shows following error message. This error sounds like need to do something different, Can you please help me on this? How can resolve this error?

---------------------------
DataGridView Default Error Dialog
---------------------------
The following exception occurred in the DataGridView:



System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

at System.Windows.Forms.ComboBox.set_AutoCompleteSource(AutoCompleteSource value)

at System.Windows.Forms.DataGridViewComboBoxCell.InitializeEditingControl(Int32 rowIndex, Object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)

at System.Windows.Forms.DataGridView.InitializeEditingControlValue(DataGridViewCellStyle& dataGridViewCellStyle, DataGridViewCell dataGridViewCell)



To replace this default dialog please handle the DataError event.
---------------------------
OK
---------------------------
Sign In or Register to comment.