“所选索引更改在comboBox中 [英] the event of " Selected index change " in comboBox

查看:54
本文介绍了“所选索引更改在comboBox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个组合框和一个DB,我希望当我从第一个comboBox中选择一个项目时,第二个comboBox从DB中显示其子字段.我在第一个comboBox中发生选定的索引更改"事件时编写了代码,但是它无法正常工作.
如何编写代码?
请帮助我

i have two combobox and a DB, I want that when i select an item from first comboBox, the second comboBox shows its subfields from DB. i write the code in the event of " Selected index change " from first comboBox ,but it doesnt work correctly.
how can i write its code?
please help me

推荐答案

第一个问题是,您为活动安排了电话.像这样的东西:
The first question is, have you wired the event. Something like:
comboBox1.SelectedIndexChanged +=
            new System.EventHandler(comboBox1_SelectedIndexChanged);


如果这样做,那么问题很可能出在您在事件中执行的代码中.由于您没有发布代码,所以最好的建议是使用调试器查看问题出在哪里.


If that''s done, the problem most likely is in the code you execute in the event. Since you didn''t post the code, the best advice is to use the debugger to see what''s going wrong.


请注意:仅当您未触发此事件时,在组合框的列表部分中更改选择.仅当您使用Enter或Dbl单击确认确认选择时才会触发,因此选择将显示在组合的编辑框部分中.这很令人困惑,但这就是引发此事件的方式.

—SA
Please pat attention: this event is not fired when you simply change selection in the list part of the combo box. It is fired only when you confirm selection with Enter or Dbl-click, so the selection is shown in the edit box part of the combo. This is confusing, but this is how this event is fired.

—SA


看看 ^ ].

检查是否有第一个下拉属性AutoPostBack="True".
Have a look on this[^].

Check whether first dropdown property AutoPostBack="True" or not.


这篇关于“所选索引更改在comboBox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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