组合框的控制索引更改事件 [英] Control index change event of a combobox
问题描述
美好的一天
我创建了一个Windows Form应用程序,该应用程序在表单上带有一个组合框.
我正在使用组合框的click事件将字典中的值读入组合框.
Good day
I have created a Windows Form application with a combobox on the form.
I am reading the values from a dictionary into the combobox by using the click event of the combobox.
private void cmbRplStatus_Click(object sender, EventArgs e)
{
dctRplStatus();
}
我已经在组合框的索引更改事件上编写了以下代码
I have written the following code on the Index change event of the combobox
if (cmbRplStatus.Text == "Active")
{
MessageBox.Show("You clicked on Active");
我遇到的问题是,当我单击组合框时,甚至在我单击组合框内部的活动框之前,都会自动出现您单击活动框"消息.
我必须更改什么,以便当我单击combox内的活动"时,必须显示您单击活动的消息?我必须控制组合框的索引更改吗?
The problem that I am having is, the moment I click on the combobox the message, "You clicked on active" automatically comes up, before I even clicked on active inside of the combobox.
What must I change so that when I click on "active" inside of the combox, then the message You clicked on active must show? Must I control the Index change of the combobox?
推荐答案
为此,您可以使用ComboBox
控件的SelectedIndexChanged
事件.这里给出一个例子
http://msdn.microsoft.com /en-us/library/system.windows.forms.combobox.selectedindexchanged(v=vs.100).aspx [
You can useSelectedIndexChanged
event of theComboBox
control for this purpose. An example is given here
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged(v=vs.100).aspx[^]
这篇关于组合框的控制索引更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!