Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropdown should show only the display member

I have bound a collection to ultracombo and I have specified the value member and display member. The collections have many columns, Now I have to show only one column in that in display and one column assigned to value member. Now i'm seeing all the columns in the collections are getting displayed as multicolumn.

//Code

 cboUltra.ValueMember = "LookupValue"
 cboUltra.DisplayMember = "LookupValueDescription"
 cboUltra.DataSource = LoadLookupDetails(Field.LookUpCode)
 UltraGridRow.Cells("FieldValue").ValueList = cboUltra

How can I achieve that?

like image 213
A Coder Avatar asked Jan 13 '23 06:01

A Coder


1 Answers

In C# you can try the following: --> Add "ultraCombo1" as you ultra combo... on form load try following code:

    private void Form1_Load(object sender, EventArgs e)
    {
        // Fill data in ultracombo datasource
        DataTable dtt = new DataTable();
        dtt.Columns.Add("ID", typeof(int));
        dtt.Columns.Add("Name", typeof(string));
        dtt.Columns.Add("Age", typeof(int));
        dtt.Columns.Add("Address", typeof(string));
        dtt.Columns.Add("Sex", typeof(string));
        dtt.Rows.Add(new object[] {1,"Name1",20,"Address 1","Male"});
        dtt.Rows.Add(new object[] { 2, "Name2", 21, "Address 2", "Male" });
        dtt.Rows.Add(new object[] { 3, "Name3", 22, "Address 3", "Female" });
        dtt.Rows.Add(new object[] { 4, "Name4", 23, "Address 4", "Male" });
        dtt.Rows.Add(new object[] { 5, "Name5", 24, "Address 5", "Female" });
        ultraCombo1.DataSource = dtt;
        ultraCombo1.DataBind();
        //---------------------------------

        // hide all but show "ID" and "Name" only

        ultraCombo1.ValueMember = "ID";
        ultraCombo1.DisplayMember = "Name";
        for (int i = 0; i < ultraCombo1.Rows.Band.Columns.Count; i++)
        {
            ultraCombo1.Rows.Band.Columns[i].Hidden = true;
        }
        ultraCombo1.Rows.Band.Columns["ID"].Hidden = false;
        ultraCombo1.Rows.Band.Columns["Name"].Hidden =  false;                                   

    }

Your ultracombo will be populated with value member of "ID" and displaymember of "Name" only..

like image 78
Sagar Dev Timilsina Avatar answered Feb 15 '23 14:02

Sagar Dev Timilsina