Topic: ComboBox我用select()选择一项时,怎么去掉它的高亮显示?

  Print this page

1.ComboBox我用select()选择一项时,怎么去掉它的高亮显示? Copy to clipboard
Posted by: elliott
Posted on: 2005-01-11 13:20

在程序初始化时,我想ComboBox组件初始化时选中其中一项,我用comboBox.select(0);
程序运行后,能选中我要的那项,但它好像是用户用鼠标拖选一样的,有高亮显示,很不好看。
请问该怎么解决? 样子如下:

2.Re:ComboBox我用select()选择一项时,怎么去掉它的高亮显示? [Re: elliott] Copy to clipboard
Posted by: film2000
Posted on: 2005-01-13 16:46

try
comboBox.clearSelection()

3.Re:ComboBox我用select()选择一项时,怎么去掉它的高亮显示? [Re: elliott] Copy to clipboard
Posted by: elliott
Posted on: 2005-01-14 09:53

TO:film2000
comboBox.clearSelection();
从名字上看好像是清除选择,那不是一个选项都没选了?为空?

我想做到的就是程序启动后默认选择 "所有人", 如果我.clearSelection();那就会选择为" " 了...

===========
偶现在在机房,没装eclipse,等下下去试试.看能不能成功. 谢谢!

4.Re:ComboBox我用select()选择一项时,怎么去掉它的高亮显示? [Re: elliott] Copy to clipboard
Posted by: glchengang
Posted on: 2005-01-16 09:33

如果是SWT,用setText()

5.Re:ComboBox我用select()选择一项时,怎么去掉它的高亮显示? [Re: elliott] Copy to clipboard
Posted by: glchengang
Posted on: 2005-01-16 09:34

setText("所有人")

6.Re:ComboBox我用select()选择一项时,怎么去掉它的高亮显示? [Re: elliott] Copy to clipboard
Posted by: cnfree
Posted on: 2005-02-17 22:59

刚刚试了一下,以前没有注意这个问题,其实只要让Combo控件失去焦点就可以达到你的效果了,比如

combo.add("hello world1");
combo.add("hello world2");
combo.add("hello world3");
combo.select(1);
shell.setFocus();


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923