How to Complex/simple bind a combobox in

Posted on 2006-05-27
Last Modified: 2012-06-21
I would like to know:

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

a simple and clear example will be appreciated.

Question by:jskfan
    LVL 14

    Assisted Solution

    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.

    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:~

    Aslo see the link below...


    Author Comment

    Can you explain the difference in a simple way please ? it's not clear on the link.

    LVL 8

    Assisted Solution

    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).


    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:

    LVL 4

    Assisted Solution


    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).
     DataSource (custTable)
     DisplayMember (custName)
     ValueMember (custId)

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

    Or using other types of simple binding:

    Author Comment

    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:

    then the other combobox


    Author Comment

    I might haven't understood in which situation I should use simple and in which I should use complex.
    LVL 4

    Assisted Solution

    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.
    LVL 4

    Accepted Solution

    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"))


    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.

    Author Comment

    I will try it later and get back with you

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article will show, step by step, how to integrate R code into a R Sweave document
    This is about my first experience with programming Arduino.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    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 …

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now