如何禁用Combobox [英] How Do I Disable Combobox

查看:373
本文介绍了如何禁用Combobox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我有两个组合框。两者都有两个值。第一个是患者类型,另一个是预约类型。在pat ...类型项是新的和现有的和apoint类型有跟进和新问题。我说当我在第一个comboobxNew中选择时,另一个组合框自动禁用。

解决方案

如果您使用的是Windows Forms,也许是最简单的实现方式你的目标是处理第一个组合框的 SelectedIndexChange事件 [ ^ ]并禁用第二个组合框(通过将其已启用属性设置为false当第一个组合框的选定项与您的逻辑匹配时。



如果您使用的是WPF,我建议绑定 IsEnabled 第二个组合框的属性到视图模型中的属性,并在第一个组合框的 SelectedItem bindi的属性时将该属性设置为false更改以适合您的逻辑。 当然,我假设您正在使用MVVM,但如果您使用的是代码隐藏,则可以使用WinForms。



/ ravi




  • 将数据绑定到两个组合框
  • 添加 SelectedIndexChanged [ ^ ]事件到第一个组合框
  • 根据第一个组合框的选择,启用/禁用第二个组合框

     combobox2.SetEnabled(false / true); 





    这些是此逻辑的通用步骤,只有我们正在使用的语言/平台的语法不同。

    告诉我你是否在实施这个问题时遇到任何问题。


http://www.mediafire.com/download/2krjzsj1ohmz3uh/How_Do_I_Disable_Combobox.rar







这是Wpf中的示例示例:)


Sir i have two comboboxes. Both have two values. 1st is for patient type and another is for appointment type. In pat... type item are New and existing and apoint type has Follow up and new problem. I say that when i select in the first comboobx "New" the another combobox disable automatically.

解决方案

If you're using Windows Forms, perhaps the simplest way to realize your goal would be to handle the first combo box's SelectedIndexChange event[^] and disable the 2nd combo box (by setting its Enabled property to false) when the first combo box's selected item matches your logic.

If you're using WPF, I recommend binding the IsEnabled property of the 2nd combo box to a property in your view model, and setting that property to false when the property of the first combo box's SelectedItem binding changes to suit your logic.  Of course, I'm assuming you're using MVVM, although the WinForms tack could be taken if you're using codebehind.

/ravi



  • bind data to the two combo boxes
  • add SelectedIndexChanged[^] event to the first combo box
  • based on the selection of fist combo box, enable/disable the second combobox

    combobox2.SetEnabled(false/true);  



    These are the generic steps for this logic, only the syntax differs for the Language/Platform which we are using.
    let me know if u face any issue in implementing this.


http://www.mediafire.com/download/2krjzsj1ohmz3uh/How_Do_I_Disable_Combobox.rar



That is sample example :) in Wpf


这篇关于如何禁用Combobox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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