我想要在combobox 下拉列表中选中某一项后,按删除按钮,则那1项就没了,下面的项自动往上排。怎样实现啊。
ComboBox2.Items.Add可以用,那是不是有个对应的ComboBox1.Items。delete,怎样用啊?急!
ComboBox2.Items.Add可以用,那是不是有个对应的ComboBox1.Items。delete,怎样用啊?急!
解决方案 »
- cobombox 与dbgrid 小小问题
- 请问,我在设计一个系统,退出软件时,总出现Exception EAccessViolation in module RX.exe at 000BE801.
- 为什么DirectoryListing属性总是为空??
- 你放我也放,来接哦,马上接帖!
- intraweb程序生成的so文件问题?
- 三层中存储过程的调用问题!做过三层的帮忙进来看看!
- 放在panel里的image的刷新问题。。。请各位帮忙找找问题在哪??
- 通过对DBGridEh中的一列求和,结果放在footer上,请问怎么把这个结果取出来用?
- 本公司招图形设计方面的程序员
- 有没有闲着的兄弟,一起来做个项目?delph类的C/S管理系统,网上合作!!!
- clientDataSet中文过滤问题
- 如何从excel导入数据?
ComboBox1.Refresh;
var
I : integer;
begin
I:=Combobox1.ItemIndex;
if i>=0 then
begin
Combobox1.Items.Delete(i);
if I=0 then
if I-1<Combobox1.Items.Count then Combobox1.ItemIndex:=0;
if (i>0) and (I-1<Combobox1.Items.Count) then
Combobox1.ItemIndex:=i-1 end
else
Combobox1.ItemIndex:=-1;end;
ComboBox1.Refresh
应该为 if I+1<Combobox1.Items.Count then Combobox1.ItemIndex:=0;吧。因Combobox1.ItemIndex应该是从0开始计的吧。(0、1、2……)。还要算上删除的是最后1个,其它Combobox1.ItemIndex值不用变。Combobox1.ItemIndex是指当前项吗?如果是当前项,那Combobox1.ItemIndex:=i-1可以删除完某项后将下面的项往上移吗?还有Combobox1.ItemIndex:=-1;是什么意思啊
combobox1.Items.Delete(combobox1.ItemIndex);
有时会出错的
另开一贴,给你详细解释那一段ComboBox1.ItemIndex := -1 表示一项也不选,即无选择项
hangguojun就在这里解释啊。我可以再加分,不需要另开一贴