1

I have 2 Lookup edits in my winform. If I select 1st Lookup edit, need to add data source to 2nd Lookup edit based on what i selected in value in 1st Lookup edit. This all function can be done at run time.

This code i use currently for 1st Lookup edit and If i select any Item from 1st Lookup edit I need to fill / attach data source to 2nd Lookup edit.

How to complete my task ?

private void lookupedit1_EditValueChanged(object sender, EventArgs e)
    {

        object row = lookupedit1.Properties.GetDataSourceRowByKeyValue(lookupedit1.EditValue) as object;

        memoedit1.Text = (row as DataRowView)["BFlatNo"].ToString() + ", " + (row as DataRowView)["BLocation"].ToString() + ".";
        memoedit2.Text = (row as DataRowView)["DFlatNo"].ToString() + ", " + (row as DataRowView)["DLocation"].ToString() + ".";

    }

Thanks in advance.

Srihari
  • 2,387
  • 9
  • 51
  • 82
  • Post your current code, so that we can see how we can fix that – Sriram Sakthivel Jan 17 '14 at 10:03
  • Hi Sriram I Updated my question please verify it. – Srihari Jan 17 '14 at 10:59
  • 1
    You've got the `row`, using that you can change `lookupedit1.DataSource` isn't it? Where you got struck – Sriram Sakthivel Jan 17 '14 at 11:15
  • Hi, In my access database 2 tables available, in that 1st table consist of name, address and some more details. In second table consist of number of product by a customers, both table consist of reference numbers & unique number. Now If i select customer name (Lookup Edit1) from table one eg "Jhon" now I need to add data source to Lookup edit2 that consist of reference numbers of that particular Customer. eg. A single Customer consist of 2 or more references on different date. how to bind that in code ? – Srihari Jan 17 '14 at 11:41

1 Answers1

3

You can do this as follows:

yourLookUpEdit.Properties.DataSource = //Your List or DataTable
Sebi
  • 3,879
  • 2
  • 35
  • 62