DataGridView AND Combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Boy am I having trouble with this.

Does anyone know here I can get a good example of using a combobox within a
dataviewgrid? No matter what I do i get all kinds of errors.

My grid is bound to a table and I want one field to be a combobox which gets
its list form another table. When I run and click on it, I get the huge error
about STA and apartments. Wow. What the heck is that.

thanks
 
Chris schreef:
Boy am I having trouble with this.

Does anyone know here I can get a good example of using a combobox within a
dataviewgrid? No matter what I do i get all kinds of errors.

I've summarized my understandings of the control here:
http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding/

My grid is bound to a table and I want one field to be a combobox which gets
its list form another table. When I run and click on it, I get the huge error
about STA and apartments. Wow. What the heck is that.

This makes me believe that the data is retrieved in a different
thread... An example of a method that would be pretty safe is the following:

void UpdateIntResult(int result)
{
// make sure this request is marshalled to the correct thread:
if (this.labelIntResult.InvokeRequired)
{
this.labelIntResult.Invoke(new MethodInvoker(delegate {
this.UpdateIntResult(result); }));
}
else
{
// we are in the right thread, perform the updates
this.myDataSource.IntResult = result;
}
}
 
Way over my head. but thank you.
I guess I do not undertsnad why I cannot just set the column to a combobox,
sets its properties like Datasource, Display Member, etc to a new table, then
bo OK. But it get the error you show on your web site. This was so much esier
in VB 6.0.
I have about had it.
 
Chris schreef:
Way over my head. but thank you.
I guess I do not undertsnad why I cannot just set the column to a combobox,
sets its properties like Datasource, Display Member, etc to a new table, then
bo OK.

That's more or less the only you have to do.. (Usually you may want to
set the ValueMember too)

I have about had it.

Just give it a rest for a day (or two) and try again. I remember that
when i started using DataGridViewComboBoxColumns i found it a
frustrating time too :) (That's only a couple of months ago :p)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top