我想在复选框上更改组合框项目文本 [英] I want to change combobox item text on checkbox checked

查看:87
本文介绍了我想在复选框上更改组合框项目文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,伙计们,我正面临一个问题,问题是我在组合框中有9个复选框和9个组合框项目,如果我选中了checkbox1,那么组合框项目1 text = checkbox1 text

请看截图

screenshot1 - imgbb.com [ ^ ]

提前感谢



我尝试过:



if(checkBox1.Checked == true)

{

comboBox2.SelectedIndex = 0;

comboBox1.SelectedItem.Text =saturday;

}

解决方案

< blockquote>如果我理解正确,你应该更改你的代码:

  if (checkBox1.Checked ==  true 
{
comboBox1.Items( 0 )= <跨度类=代码串>星期六;
}



'SelectedItem'也会起作用 - 但只有你已经选择了一个项目。

另外你应该确定您要使用的每个项目都是现有的......


Hello, Guys, I am facing an issue and issue is I have 9 checkboxes and 9 combo box item in combo box I want if I checked checkbox1 so combo box item 1 text = checkbox1 text
please see the screenshot
screenshot1 — imgbb.com[^]
thanks in advance

What I have tried:

if(checkBox1.Checked == true)
{
comboBox2.SelectedIndex = 0;
comboBox1.SelectedItem.Text = "saturday";
}

解决方案

If I understood it right you should change your code like this :

if(checkBox1.Checked == true)
 {
 comboBox1.Items(0) = "saturday";
 } 


'SelectedItem' will work too - but only if you have allready select an Item.
Also you should make sure that each Item you want to use is existing ...


这篇关于我想在复选框上更改组合框项目文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆