John Solomon
asked on
C# DropDown smart logic implementation
Hi Experts,
I've got a ComboBox in ComboBoxStyle.DropDownList style.
This gets dunamically created based on the number of a passed parameter. The letters is an ArrayList of letters which are added to the dropdown
I've been trying to create a method so that when I click on a dropdown list, the letters which are already selected should not show up from the selections. Like on the image above, If I click on M, then M should not show up. If I select V, then V should be selected, not show on the list, M should be added.
I'm not sure how to actually do this. I wonder if I should have two ArrayLists (one holds the letters used in the dropdown, and another one to hold all the unused letters).
I am looking at an exact implementation like this (in javascript) but obviously in C#. I've tried to convert the javascript method to C#, but I was not successful.
Please kindly point me to a good starting point. I've tried so many methods, but no success..
Thanks!
I've got a ComboBox in ComboBoxStyle.DropDownList
This gets dunamically created based on the number of a passed parameter. The letters is an ArrayList of letters which are added to the dropdown
for (int a = i; a < drivesLetters.Count; a++)
{
combobox.Items.Add(drivesLetters[a]);
}
I've been trying to create a method so that when I click on a dropdown list, the letters which are already selected should not show up from the selections. Like on the image above, If I click on M, then M should not show up. If I select V, then V should be selected, not show on the list, M should be added.
I'm not sure how to actually do this. I wonder if I should have two ArrayLists (one holds the letters used in the dropdown, and another one to hold all the unused letters).
I am looking at an exact implementation like this (in javascript) but obviously in C#. I've tried to convert the javascript method to C#, but I was not successful.
Please kindly point me to a good starting point. I've tried so many methods, but no success..
Thanks!
ASKER
Hi Kyle Abrahams, thank you for your answer. However, I am not sure how this method would achieve my goal.
If index is equal to combobox selectedIndex, then redraw a rectangle combobox?.
I might have confused you with my question, and I see that the javascript link was not working.. I was hoping to get something like this combo box selection implementation.
Where a number of comboboxes {combo1, combo2. combo3} are filled with a list of letters {A,B,C,D,E, F, G, H}. In order to prevent a user from choosing the same letter A in combo1 and combo3, if A is already selected in combo1, then it should not show up in combo3 dropdown. Given than letter A is unselected in combo1 and is not selected in any other comboboxes, then letter A should be available in a comboboxes dropdown as selectable.
Thank you very much for your help :)
If index is equal to combobox selectedIndex, then redraw a rectangle combobox?.
I might have confused you with my question, and I see that the javascript link was not working.. I was hoping to get something like this combo box selection implementation.
Where a number of comboboxes {combo1, combo2. combo3} are filled with a list of letters {A,B,C,D,E, F, G, H}. In order to prevent a user from choosing the same letter A in combo1 and combo3, if A is already selected in combo1, then it should not show up in combo3 dropdown. Given than letter A is unselected in combo1 and is not selected in any other comboboxes, then letter A should be available in a comboboxes dropdown as selectable.
Thank you very much for your help :)
ASKER
Hi Kyle, or an implementation like this. Thanks
ASKER
Or this is a closer implementation that I am looking for javascripcode
I'll try to learn and convert this code into C#. But your help will be greatly appreciated. :) thanks!
I'll try to learn and convert this code into C#. But your help will be greatly appreciated. :) thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Without having a VS currently at hands, my approach would be using the MeasureItem event to set the height of the item to 0 and skip it in your own owner draw event.
Something like:
Open in new window