[英]How to change label's text depending on item selected on a combo box which is populated using SQLite?
[英]How do i change a label to match the selected index of a combo box?
在这里,我有一些工作正常的代码。 除了我需要的东西,它现在做得最好。
我有一个我已命名的标签( lblProfileID ),我需要这个标签来显示与( ProfileName )匹配的( ProfileID ),具体取决于我在组合框中所做的选择 ,其中存储了所有的Profilenames。
我如何完成这项任务?
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); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.