Forum  Core :: SDK (Vi...  Developing the ...  Binding combobox
Previous Previous
 
Next Next
New Post 4/13/2009 12:59 PM
  avalor
119 posts
5th Level Poster


Binding combobox 

Hi,

   i know this question dont have to be here, but you always help me, in a form how can i have a combo box binded to a datagridview, i get the value of the table in the combo box, but if i want to obtain the description from the foreign table? i cant join tables because i cant update, delete, because im using table adapters and datasets of the ide, thanks for your answer!

 
New Post 4/13/2009 2:39 PM
  palli
11189 posts
1st Level Poster




Re: Binding combobox 

Hi avalor,

You can not bind your combobox to your datagridview. You can however bind your combobox to the same table(s) as your DataGridView is bound to....

You say you are using the tableadapters and datasets if the IDE, does that mean that you have a strongly typed dataset, where the description of all your physical database tables is represented? If you do, there is no problem adding seperate "tables" in your VStudio offline dataset, where you can join multiple tables from your database.

Let's say you have a transactions table with a customer number and then you have a customers table with a customernumber and a name. Both of these tables would be represented as tables within your VStudio dataset. You then could add a query to your offline dataset where you join the transaction table and the customers table, so that from your C# or vb.net program, they looks like any other table.

The possibilities are endless, you just need to tell us more specifically what you need.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 4/13/2009 4:48 PM
  avalor
119 posts
5th Level Poster


Re: Binding combobox 

 

if i use a join between client and city tables i cant update or delete, then how i can my combobox using the same binding source to have the correct name of city of the client,  and to populate all the cities of the catalog if i want to update

 
New Post 4/13/2009 5:05 PM
  palli
11189 posts
1st Level Poster




Re: Binding combobox 

Hi avalor,

Might be that I'm not understanding you correctly, but from the image it seems to me that you will have a list of records in the DataGridView that will contain a city ID. Then you have the combobox that should change as you select different records in the datagridview, but you don't want the city ID do show in the combobox, you want the city name, right ?

I think you might find some valuable information in this code sample here. Check the usercontrol, UC.vb and check the code for AssignDataset() in that file. There you have a datagridview, and then a combobox and two textboxes outside of the datagridview, that bind to the data in the selected record in the DataGridView.

Remember that in .NET you have actually two "things" that relate to data-something. First you have the DataSource of some controls like the DataGridView that is the list of records that will show in the control. Comboxes have similar DataSource (plus DisplayMember and ValueMember) that will be presented as a list of available options.

Second you have databindings. This means in your case you will create a databinding for your combobox that you will databind to the bindingsource of your datagrid and the effect will be that every time you select a different record in the DataGridview, the value will automatically change in the combobox.

Check the code sample and see if you get the general idea.

Feel free to ask more if I misunderstood, or if you need more info.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
Previous Previous
 
Next Next
  Forum  Core :: SDK (Vi...  Developing the ...  Binding combobox
Assessment Bottom
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS