简体   繁体   English

如何在RepositoryItemComboBox中隐藏Item?

[英]How to hide Item in RepositoryItemComboBox?

Hi I am using devExpress on winform. 嗨,我在winform上使用devExpress。 I have a list of items wholeList = {Item1, Item2, Item3, Item4,Item5,Item6}, and I have another two lists: ActionAList = {Item1, Item3, Item5}, ActionBList = {Item2, Item4, Item6}. 我有一个项目清单WholeList = {Item1,Item2,Item3,Item4,Item5,Item6},还有另外两个清单:ActionAList = {Item1,Item3,Item5},ActionBList = {Item2,Item4,Item6}。 I have a grid view on my form. 我在表格上有一个网格视图。 And I have two columns "Action" and "Item" on this grid. 在此网格上,我有两列“动作”和“项目”。 Each column has a repositoryItemComboBox as in-place editor. 每列都有一个repositoryItemComboBox作为就地编辑器。

In the dropdown of "Action", I have "ActionA" and "ActionB". 在“动作”的下拉列表中,我有“动作A”和“动作B”。 In the dropdown of "Item", I have all the 6 items Item1 to Item6. 在“项目”的下拉列表中,我拥有6个项目Item1至Item6。 When I select ActionA, I want Item dropdown only displays Item1, Item3, and Item5. 当我选择ActionA时,我希望Item下拉列表仅显示Item1,Item3和Item5。 The same when I select ActionB, I want Item dropdown only displays Item2, Item4 and Item6. 与选择ActionB时相同,我希望Item下拉列表仅显示Item2,Item4和Item6。

I think when user selects different Action (either A or B), I can clear the repositoryItems in Item dropdown, and add either ActionAList or ActionBList back to repositoryItem. 我认为,当用户选择其他操作(A或B)时,我可以清除“项目”下拉列表中的repositoryItems,然后将ActionAList或ActionBList添加回repositoryItem。 But I feel uncomfortable, because it is possible at this point of time, the available items in Item dropdown are only Item1,3 and 5, but another row may still keep ActionB and Item2. 但是我感到不舒服,因为此时有可能,Item下拉列表中的可用项目仅为Item1、3和5,但另一行仍可能保留ActionB和Item2。

I wonder what would be the best way to archive this requirement. 我想知道什么是归档此要求的最佳方法。 I also think of whether we have any method to hide some items in the whole list. 我还考虑是否有任何方法可以隐藏整个列表中的某些项目。 So when the user open the editor of Item dropdown. 因此,当用户打开Item下拉菜单的编辑器时。 According to the current row's action value, I may just display items in ActionAList or in ActionBList. 根据当前行的操作值,我可以仅在ActionAList或ActionBList中显示项目。 But I am not able to find such property when I create ComboBoxItem or ImageComboBoxItem. 但是创建ComboBoxItem或ImageComboBoxItem时找不到此类属性。

Thanks for any input! 感谢您的输入!

Firstly, please remember that repositoryItems are only templates to construct editors for each row in GridView. 首先,请记住,repositoryItems只是用于为GridView中的每一行构造编辑器的模板。 The only way to control editors on cell basis is handling CustomRowCellEdit event (where you can choose existing editor or create custom editor). 在单元格上控制编辑器的唯一方法是处理CustomRowCellEdit事件(您可以在其中选择现有编辑器或创建自定义编辑器)。

Secondly, you have to handle CellValueChanged event to clear column 'Item' every time the user changes value in column 'Action' in order to avoid situation you've described (Item from ActionBList when Action = A). 其次,每次用户更改“动作”列中的值时,必须处理CellValueChanged事件以清除“项目”列,以避免出现您所描述的情况(当Action = A时,ActionBList中的项目)。

Regards, 问候,

Maciej Nowicki 麦基·诺维奇

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM