简体   繁体   中英

How do i change a label to match the selected index of a combo box?

Here i have some code that works fine. Except the thing i need it do the most right now.

I have a label which i've named ( lblProfileID ) and i need this label to display the ( ProfileID ) that matches the ( ProfileName ) depending on the selection i've made in the combobox where all the Profilenames are stored.

How do i accomplish this task?

       public void QueriesProfile()
    {
        QueryResult queryResultProfile = null;
        String SOQL = "";
        SOQL = "Select Id, Name from Profile";
        queryResultProfile = Sfdcbinding.query(SOQL);

        string profileID = null;
        string ProfileName = null;

        if (queryResultProfile.size > 0)
        {
            for (int i = 0; i < queryResultProfile.size; i++)
            {
                Profile userProfile = (Profile)queryResultProfile.records[i];
                profileID = userProfile.Id;
                ProfileName = userProfile.Name;

                string[] uSersProfile = { ProfileName, profileID };
                listProfile.AddRange(uSersProfile);
                cmbProfile.Items.Add(ProfileName);

                lblProfileID.Text = cmbProfile.SelectedIndex(profileID); /// <--- How do i do this?
            }
        }
    }

  public void QueriesProfile() { cmbProfile.SelectedIndexChanged+=cmbProfile_SelectedIndexChanged; QueryResult queryResultProfile = null; String SOQL = ""; SOQL = "Select Id, Name from Profile"; queryResultProfile = Sfdcbinding.query(SOQL); string profileID = null; string ProfileName = null; if (queryResultProfile.size > 0) { for (int i = 0; i < queryResultProfile.size; i++) { Profile userProfile = (Profile)queryResultProfile.records[i]; profileID = userProfile.Id; ProfileName = userProfile.Name; string[] uSersProfile = { ProfileName, profileID }; listProfile.AddRange(uSersProfile); cmbProfile.Items.Add(ProfileName); } } } private void cmbProfile_SelectedIndexChanged(object sender, EventArgs e) { lblProfileID.Text = cmbProfile.SelectedIndex(profileID); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM