如何在组合框C#Windows应用程序中禁用所选项目? [英] How do I disable selected item in combobox C# Windows application?

查看:107
本文介绍了如何在组合框C#Windows应用程序中禁用所选项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两个组合框。



当我选择combobox1时,目录中的所有文件都列在comboBox2中。



我想锁定用户在combobox1中选择的项目,这样其他用户就无法选择相同的项目了。我有相应的数据库,其中将保存状态标志。



任何帮助或建议表示赞赏。



谢谢。

I am working with two comboboxes.

When I select combobox1 all the files from the directory are listed in the comboBox2.

I want to lock the item selected by user in combobox1 so no other user can select the same item. I have corresponding database where status flag will be saved.

Any help or suggestions appreciated.

Thanks.

推荐答案

如果您的目标是禁用ComboBox中的某些项目,可以使用DrawItem和SelectedIndexChanged事件来完成。

您还需要确定项目索引的逻辑( es)应该是灰色的。



这是StackOverflow的一个例子禁用组合框中的特定项目 [ ^ ]你可以用作起点。



我不建议用力但是,例如,在这个例子中的编码索引。



如果这是用于实现您的解决方案的正确控件,则是另一回事。
If your goal is to disable certain items in a ComboBox it can be done by using the DrawItem and SelectedIndexChanged event.
You also need to determine the logic for which item index(es) that should be grayed out.

Here is an example from StackOverflow Disabling particular Items in a Combobox[^] that you can use as a starting point.

I would not recommend to use hard coded indexes like in that example, though.

And if this is the right controls to use in order to implement your solution is a different story.


这篇关于如何在组合框C#Windows应用程序中禁用所选项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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