导航:
论坛 -> 移动应用开发
斑竹:flyers,iamdream
作者:
2023/8/27 13:57:35
标题:
新手请问ComboBox的Items添加太慢的问题
浏览:504
加入我的收藏
楼主:
在安卓环境下我有3个combobox,启动时需要绑定一样的TStringList名为list1,里面有几千个字符串,但是每次启动都比较耗时,怎样才能最快呢? ComboBox1.BeginUpdate; ComboBox2.BeginUpdate; ComboBox3.BeginUpdate; ComboBox1.Items.BeginUpdate; ComboBox2.Items.BeginUpdate; ComboBox3.Items.BeginUpdate; ComboBox1.items := list1; ComboBox2.items := list1; ComboBox3.items := list1; ComboBox1.Items.endUpdate; ComboBox2.Items.endUpdate; ComboBox3.Items.endUpdate; ComboBox1.endUpdate; ComboBox2.endUpdate; ComboBox3.endUpdate;
----------------------------------------------
-
作者:
2023/8/27 17:18:18
1楼:
耗时多少? 实在时间长,那就启动时,不要绑定,启动完成后,界面显示出来后,界面上显示一个进度条或者转圈圈,给个提示:数据处理中... 然后再开始绑定。 或者再玩个技巧,绑定的那个 StringList 里面只有 50 个字符串。启动完成后,后面再用一个循环,从另外一个 StringList 里面,分多次把其它字符串填进去。也就是说你那几千个字符串,先放到另外一个缓存用的 StringList 里面去。
----------------------------------------------
-
作者:
2023/8/27 21:55:30
2楼:
@ pcplayer 谢谢 耗时5秒 这个可以用livebindings来绑定吗 会不会快点呢
----------------------------------------------
-
作者:
2023/8/27 22:00:53
3楼:
FMX 底下,肯定可以用 LiveBinding 来绑定。会不会快就不知道了。 实际上我不知道你的慢,究竟慢在哪里。
----------------------------------------------
-
作者:
2023/8/27 22:10:52
4楼:
@pcplayer 假如用可视化绑定的话里面没有items这个选项呢 是绑定items.commatext吗 拖过去是禁止绑定状态 无效呢
此帖子包含附件: 大小: 41.1K
----------------------------------------------
-
作者:
2023/8/27 22:11:51
4楼:
有个问题:ComboBox.Items 里面有几千条?用户怎么选?这个是下拉给用户选择的。几千条,用户怎么选择啊?用户操作的友好度太低了。程序不应该这样写。
----------------------------------------------
-
作者:
2023/8/27 22:12:42
5楼:
是的 可以选 字符串有规律的 很好找 combobox可以滚动的
----------------------------------------------
-
作者:
2023/8/28 8:49:07
6楼:
我觉得4楼说的对, 你应该换个方式来操作这个,几千条记录实在不适合组合框下拉选择!!!
----------------------------------------------
-
作者:
2023/8/28 11:29:33
7楼:
Item.Text 好像确实不能从别的控件拉线 -- 如果拉线它不支持,那可能是不支持绑定。 不过也可以理解:动态绑定的意思,是当数据变化时,界面显示变化;而这个 Items 的内容是给用户选择用的,理论上是不变的。
----------------------------------------------
-
作者:
2023/8/28 11:53:39
8楼:
combobox加载几千条数据,从实际使用来说,没有多大意义,找个数据找死人
----------------------------------------------
欢迎加入Delphi的QQ群:553554446
作者:
2023/8/28 12:17:15
9楼:
让用户从几千条数据里面找东西的情况,我用 DBGridEh 来显示这几千条数据,利用它上面的那个搜索框,输入部分字符,它自动搜索或过滤。 当然,这个是 VCL 的。FMX 底下,可以想办法做类似的东西。这样才用户友好。
----------------------------------------------
-
作者:
2023/8/29 19:46:08
10楼:
好的 多谢各位
----------------------------------------------
-
作者:
2023/8/30 15:08:16
11楼:
假如有个字符串数组ss我绑定combobox1的items,请问两个问题. 1.只要ss变化combobox1的items也跟着变化,用代码如何实现呢? 2.combobox1.items:=ss和combobox1.items.assign(ss)这两个方法有什么区别?
----------------------------------------------
-
作者:
2023/8/30 23:43:08
12楼:
Source is your anwer: ComboBox1.Items := ss; => FListBox.Items.Assign(Value); *TCustomComboBox .... FListBox.Items.Assign(Value); => TStrings.Assign(Source: TPersistent); ComboBox1.Items.Assign(ss); => FListBox.Items.Assign(Value); .... FListBox.Items.Assign(Value); => TStrings.Assign(Source: TPersistent);
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
2023/8/31 0:41:51
13楼:
@emailx45 也就是两种方法本质一样,那么如何实现把ss当做数据源绑定呢
----------------------------------------------
-
作者:
2023/8/31 3:14:07
14楼:
see my post if help you, Im using StringGrid + ComboBox + LiveBinding connection https://bbs.2ccc.com/topic.asp?topicid=682294
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
2023/8/31 14:03:43
15楼:
@emailx45 谢谢,这个方法只能绑定组件之间的属性,不能绑定一个数组吗? 假如我绑定两个combobox的items是这样操作吗,为什么没用呢?
此帖子包含附件: 大小: 46.6K
----------------------------------------------
-
作者:
2023/8/31 21:25:51
16楼:
using LiveBinding you can create yourself "class" and use "TAdapterBindSource" to use your class like a "source of data"... then, if your classe has a "array values in some property (for example)", theorically, you can do it!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
2023/8/31 21:46:56
17楼:
... Look my post again... TComboBox <---> TComboBox sinchronization https://bbs.2ccc.com/topic.asp?topicid=682294
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3