HighTechTalks DotNet Forums  

Cant leave databinded comboboxes

Dotnet Framework (WinForms DataBinding) microsoft.public.dotnet.framework.windowsforms.databinding


Discuss Cant leave databinded comboboxes in the Dotnet Framework (WinForms DataBinding) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
erah
 
Posts: n/a

Default Cant leave databinded comboboxes - 12-18-2007 , 05:56 AM






Hi!

I have som problems using drag n drop functionallity in visualstudio 2005.

I have created a dataset from my sqlexpress with one main table and three
valuetables using IDnumbers to get the realname of each child..

I then created a datagridview and changed the IDvalues ( FKs ) to databinded
comboboxes to display the correct values. So far so good all values are
displayed correctly!

When I try to drag n drop the detail ( as comboboxes ) these are to be used
to select values to change/add the data in the datagrid.
the bindings are set as follows:

Datasource: NameBindingSource
Displaymember: Name
Value Member: NameID
Selected Value: MainBindingSource - NameID

This works as long as I only use ONE combobox, if I add anotherone from
another table as follows:

Datasource: LastNameBindingSource
DisplayName: LastName
Value Member: LastNameID
Selected Value: MainBindingSource - LastNameID

The result will be that when I select a LastName I cant leave that combobx.
No other event will respond, the only solution is to kill the application.

Today I noticed that if I manually add numeric values to in my database it
will work for the numeric values only.

Is this a known bug or is it me using bindings the wrong way?

I have a ready example to upload if theres anyone interested in this problem.
--
kind regards Erik
Developer

Reply With Quote
  #2  
Old   
Morten Wennevik [C# MVP]
 
Posts: n/a

Default RE: Cant leave databinded comboboxes - 12-20-2007 , 06:38 AM






Hi Erik,

Without knowing the details it looks like you encounter some kind of eternal
loop, although I could not reproduce your problem using a BindingList as
source for two BindingSources. Selecting a person from the second comboBox
would update NameID of the selected person from the first ComboBox

My setup code was as follows. Person is a business object having a string
Name and int Id property

Person personA = new Person("Pete", 1);
Person personB = new Person("James", 2);
Person personC = new Person("Richard", 3);
_personList.Add(personA);
_personList.Add(personB);
_personList.Add(personC);

dataGridView1.DataSource = _personList;

sourceMain = new BindingSource(_personList, "");
sourceLast = new BindingSource(_personList, "");

comboBox1.DataSource = sourceMain;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Id";

comboBox2.DataSource = sourceLast;
comboBox2.DisplayMember = "Name";
comboBox2.ValueMember = "Id";

comboBox2.DataBindings.Add("SelectedValue", sourceMain, "Id");

--
Happy Coding!
Morten Wennevik [C# MVP]


"erah" wrote:

Quote:
Hi!

I have som problems using drag n drop functionallity in visualstudio 2005.

I have created a dataset from my sqlexpress with one main table and three
valuetables using IDnumbers to get the realname of each child..

I then created a datagridview and changed the IDvalues ( FKs ) to databinded
comboboxes to display the correct values. So far so good all values are
displayed correctly!

When I try to drag n drop the detail ( as comboboxes ) these are to be used
to select values to change/add the data in the datagrid.
the bindings are set as follows:

Datasource: NameBindingSource
Displaymember: Name
Value Member: NameID
Selected Value: MainBindingSource - NameID

This works as long as I only use ONE combobox, if I add anotherone from
another table as follows:

Datasource: LastNameBindingSource
DisplayName: LastName
Value Member: LastNameID
Selected Value: MainBindingSource - LastNameID

The result will be that when I select a LastName I cant leave that combobx.
No other event will respond, the only solution is to kill the application.

Today I noticed that if I manually add numeric values to in my database it
will work for the numeric values only.

Is this a known bug or is it me using bindings the wrong way?

I have a ready example to upload if theres anyone interested in this problem.
--
kind regards Erik
Developer

Reply With Quote
  #3  
Old   
Erik
 
Posts: n/a

Default RE: Cant leave databinded comboboxes - 01-03-2008 , 10:06 AM



Yes that works fine but..

Im using visual studio 2005 ( latest service packs and so on )

Im using autogeneratade code first by creating a Dataset thru the guide in
"datasources"
when thats done Im creating a datagrid from "data Source" and all fields
created the same way ( like in the instruction videos )

everything is so far connected automatically ..

using four tables I get 4 bindingsources and 4 table adapters.
the main table has FKs to the 3 valuetables where I get the names I want to
display.

Is there someplace I can upload an example I ve created.. ?

If I in one combobox select a vaule that doesnt work I can select a
different value and the "lock" will go away I can even select the value that
caused the lock.

I have 3 developers working with this issue and noone of them has come up
with a solution .. we are getting out of Ideas
(We can reproduce the error only with 2 or more comboboxes)

kind regards Erik



"Morten Wennevik [C# MVP]" wrote:

Quote:
Hi Erik,

Without knowing the details it looks like you encounter some kind of eternal
loop, although I could not reproduce your problem using a BindingList as
source for two BindingSources. Selecting a person from the second comboBox
would update NameID of the selected person from the first ComboBox

My setup code was as follows. Person is a business object having a string
Name and int Id property

Person personA = new Person("Pete", 1);
Person personB = new Person("James", 2);
Person personC = new Person("Richard", 3);
_personList.Add(personA);
_personList.Add(personB);
_personList.Add(personC);

dataGridView1.DataSource = _personList;

sourceMain = new BindingSource(_personList, "");
sourceLast = new BindingSource(_personList, "");

comboBox1.DataSource = sourceMain;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Id";

comboBox2.DataSource = sourceLast;
comboBox2.DisplayMember = "Name";
comboBox2.ValueMember = "Id";

comboBox2.DataBindings.Add("SelectedValue", sourceMain, "Id");

--
Happy Coding!
Morten Wennevik [C# MVP]


"erah" wrote:

Hi!

I have som problems using drag n drop functionallity in visualstudio 2005.

I have created a dataset from my sqlexpress with one main table and three
valuetables using IDnumbers to get the realname of each child..

I then created a datagridview and changed the IDvalues ( FKs ) to databinded
comboboxes to display the correct values. So far so good all values are
displayed correctly!

When I try to drag n drop the detail ( as comboboxes ) these are to be used
to select values to change/add the data in the datagrid.
the bindings are set as follows:

Datasource: NameBindingSource
Displaymember: Name
Value Member: NameID
Selected Value: MainBindingSource - NameID

This works as long as I only use ONE combobox, if I add anotherone from
another table as follows:

Datasource: LastNameBindingSource
DisplayName: LastName
Value Member: LastNameID
Selected Value: MainBindingSource - LastNameID

The result will be that when I select a LastName I cant leave that combobx.
No other event will respond, the only solution is to kill the application.

Today I noticed that if I manually add numeric values to in my database it
will work for the numeric values only.

Is this a known bug or is it me using bindings the wrong way?

I have a ready example to upload if theres anyone interested in this problem.
--
kind regards Erik
Developer

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.