By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,214 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,214 IT Pros & Developers. It's quick & easy.

DataGridView AND Combobox

P: n/a
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
Jan 31 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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-datagr...n-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;
}
}
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Jan 31 '07 #2

P: n/a
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.
"Tim Van Wassenhove" wrote:
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-datagr...n-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;
}
}
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Feb 1 '07 #3

P: n/a
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)
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Feb 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.