具有添加和删除项目的已排序组合框列表 [英] A sorted combobox list with adding and removing items

查看:101
本文介绍了具有添加和删除项目的已排序组合框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个组合框,在该组合框中对列表进行排序,并且可以添加和删除项目,而不会破坏先前选择的索引.在Visual Basic中.

I am trying to develop a combobox where the list is sorted, and items can be added, AND REMOVED, without screwing up the indexes of the previous selections.  In Visual Basic.

(还有许多组合框,它们都共享相同的列表,并且每个组合框都可以将项目添加到列表中.我的那部分工作得很好.请参阅我之前关于该主题的文章.)现在,我试图使它也可以排序和删除项目, 而不弄乱先前的选择索引.因此,我认为最好是每个组合框都不进行自己的排序.而是将列表排序一次(添加或删除项目时),然后与许多组合框共享.还 我假设一旦分配了给定的选择索引,则从列表中删除一个项目后就不会再次重新分配它.这样,随着其他项目的添加或删除,每个列表项都将永久拥有自己的唯一选择索引.

(Also, there are many comboboxes where they all share the same list, and each combobox can add items to the list.  I have that part working well.  See my previous post on that topic.)  Now I'm trying to get it to also sort, and remove items, without messing up the prior selection indexes.  So I assume it would be best if each combobox does not do its own sorting.  Instead, the list is sorted once (when items are added or removed), and then shared with the many comboboxes.  Also I assume that once a given selection index is assigned, it is not re-assigned again after an item is removed from the list. That way, each list item permanently holds its own unique selection index, as other items are added or removed. 

我不知道从哪里开始.感谢您提供的任何帮助.

I have not idea where to begin on this one.  Thank you for any help you may give.

-沃尔特·斯纳夫(Walter Snafu)

-- Walter Snafu

推荐答案

从数组中删除项目时,您必须始终从最后一个索引开始并移向索引0.如果向前移动并删除索引3,则转到下一个索引4时,您正在查看的原始数据是索引5.你呢 会完全跳过索引4.
When removig items from an array you must always start at the last index and move toward index 0.  If you move forward and delete index 3, when you go to the next index 4 you are looking at the data that was originally at index 5.  You in effect skip index 4 completely.


这篇关于具有添加和删除项目的已排序组合框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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