How to add data source to Lookup Edit at run time?

8.8k views Asked by At

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.

1

There are 1 answers

0
Sebi On BEST ANSWER

You can do this as follows:

yourLookUpEdit.Properties.DataSource = //Your List or DataTable