?
Solved

How to Complex/simple bind a combobox in vb.net

Posted on 2006-05-27
9
Medium Priority
?
857 Views
Last Modified: 2012-06-21
I would like to know:

How to Complex/simple bind a combobox in vb.net ? what does it mean? in which circumstance it is used?

a simple and clear example will be appreciated.

thanks
0
Comment
Question by:jskfan
9 Comments
 
LVL 14

Assisted Solution

by:MilanKM
MilanKM earned 390 total points
ID: 16776369
Data binding is divided into two categories: simple and complex binding. Simple binding means low level binding, where as complex binding means high level binding.

Simple data binding means a single value of a data source is bound to a control. Any property of a component can be bound to any value of a data source. For example you can bind the Text property of a TextBox to a column of a table.
http://www.exforsys.com/content/view/1547/350/

Complex data binding means a control is bound to a data source and examines and handles the structure by itsself. Examples for this category are the DataGrid and the ComboBox control. See more:~ http://www.exforsys.com/content/view/1548/350/

Aslo see the link below...
http://www.codeproject.com/vb/net/databindingconcepts.asp

Thanks
MilanKM
0
 

Author Comment

by:jskfan
ID: 16779319
Can you explain the difference in a simple way please ? it's not clear on the link.

thanks
0
 
LVL 8

Assisted Solution

by:YoungBonzi
YoungBonzi earned 390 total points
ID: 16780158
Simple Data Binding
Simple data binding means binding a single value within the data model to a single property of a control. For example, binding TextBox1.Text to Customer.Name.

Complex Data Binding
Complex data binding means binding a control to a collection (rather than binding a control to a single item within the collection).

http://www.dotnetjunkies.com/quickstart/winforms/doc/WinFormsData.aspx


============

In the real world, the biggest difference is that simple binding can only show one element at a time, but complex binding can fill an entire grid.

To understand for your self build this tutorial on your own, you'll see the difference:

simple: http://blogs.msdn.com/ariroth/archive/2004/12/17/323807.aspx
complex: http://blogs.msdn.com/ariroth/archive/2005/01/21/358478.aspx
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Assisted Solution

by:NicoLaan
NicoLaan earned 570 total points
ID: 16783305
Example:

Combobox used to identify who (from custTable) bought an item (data stored in salesTable):

You'd (complex) bind the customer names to the various items in the combobox (the list you see when you click it).
Properties:
 DataSource (custTable)
 DisplayMember (custName)
 ValueMember (custId)

You'd simple bind the selected value to the SalesTable.
Properties:
 SelectedValue (will hold the selected custId)

Or using other types of simple binding:
 SelectedIndex
 SelectedItem
 SelectedText
0
 

Author Comment

by:jskfan
ID: 16790155
I have tried both simple and complex databinding to 2 comboboxes and they show the same thing. the whole list of customers names

I used for one combobox:
DataSource
DisplayMember
ValueMember


then the other combobox
DataSource
SelectedValue

0
 

Author Comment

by:jskfan
ID: 16790159
I might haven't understood in which situation I should use simple and in which I should use complex.
0
 
LVL 4

Assisted Solution

by:NicoLaan
NicoLaan earned 570 total points
ID: 16794092
Simple binds to 1 record, i.e. a textbox.
Complex binds to all rows in the table, i.e. the list of items in a combobox or a datagrid.
The selected value in the combobox would be bound with simple binding, the list of items with complex binding.

I forgot to mention some property I think, will look from work tomorrow (12 hours from now) if I can.
0
 
LVL 4

Accepted Solution

by:
NicoLaan earned 570 total points
ID: 16797290
Ah, now I remember (now I see it).

Simple binding works like this:

ControlName.DataBindings.Add(New Binding("name of property from control to bind", "DataTable", "DataField"))

i.e.

Combobox1.DataBindings.Add(New Binding("SelectedValue", "SalesTable", "CustId"))

Now any value you select in the combobox will be changed in the SalesTable.CustId.
If you want it to respond to the text edited in the combobox you should use SelectedText I think.

So for simple binding, don't use the datasource property, that's only used in the complex binding.

Of course for a combobox you'll mostly want to use both complex and simple binding. Complex to show all CustId's from CustTable in the list, simple to get the selected value in the SalesTable.

In my examples I assumed SalesTable to hold something like this: CustId, ProductId, Date of sale, amount of sale. I only describe the part for the CustId. But I think you might've understood all this already.
0
 

Author Comment

by:jskfan
ID: 16798181
I will try it later and get back with you
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question