Delphi - ListView 或类似的所有者绘制按钮
如何创建每行都有一个按钮的列表视图(或类似视图)?该按钮需要能够根据需要在每行上具有不同的文本/颜色。
我确信虚拟树视图非常适合此操作,但我对此有点迷失。
谢谢
-布拉德
How do I do create a listview (or similar) with a button on each line? The button needs to be able to have different text/color on each line as required.
I'm sure Virtual Treeview would be perfect for this, but I'm a little lost with it.
Thanks
-Brad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 virtualtreeview...... 将 vstButton 添加到您的用途中,并在对象检查器中选择您的 Virtualtreeview 并为您的树设置以下事件:
...这假设记录是:
...添加以下单元:
上面代码基于此网站上找到的代码:
http://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus
如果您查看单元 vstButton,要获得 TEdit 或 TCombo...等...只需将任何 TButton 引用替换为 TEdit 或 TCombo 等...调整它的事件等...上面的链接代码实际上使用TCombo
这个网站帮助我学习了如何使用 virtualtreeview
上面的代码将在每个单元格中插入一个 Tbutton,当您单击该按钮时,它将打开一个 BrowseForFolder 对话框并将结果插入到 virtualtreeview 单元格中
希望这对您有所帮助,
您是否希望单元格列中的按钮始终可见?可以用图像模拟按钮...就像单元格一侧的下拉标记
With a virtualtreeview...... add vstButton to your uses and select your Virtualtreeview in the object inspector and set the following events for your tree:
... this assumes the record is:
...add the following unit:
the above code is based upon code found at this website:
http://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus
If you look at the unit vstButton, to get a TEdit, or TCombo...etc... just replace any TButton reference with TEdit or TCombo etc... adjust events for it etc... The above link code actually uses a TCombo
that website helped me alot to learn how to use the virtualtreeview
the above code will insert a Tbutton into every cell, and when you click on the button it will open a BrowseForFolder dialog and insert the result back into the virtualtreeview cell
Hope this helps
did you want a button visible in a cell column all the time? Could simulate the button with an image... like a dropdown mark on one side of the cell