Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Comments
Sergey Alexandrovich Kryukov 30-Apr-15 15:13pm    
Depending on the ComboBox type, there should be Enabled or IsEnabled property. What's the problem?
—SA
Atta Ur Rahman 118 30-Apr-15 15:17pm    
I mean that when i select in first combobox( Type of Patient) "New" the 2nd Combobox (Type of Appointement )Disable And if i select in first combobox " Existing" it will be enable.
Sergey Alexandrovich Kryukov 30-Apr-15 15:21pm    
1) ComboBox type, please; 2) what's the problem with that?
—SA
Atta Ur Rahman 118 30-Apr-15 15:24pm    
Combobox type in database is (Nvarchar)...
Atta Ur Rahman 118 30-Apr-15 15:26pm    
I mean that how the 2nd combobox will be disable if i click "New" in the 1st combobox.

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
 
Share this answer
 

  • 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
    C#
    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.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900