DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: hfh9801
今日帖子: 0
在线用户: 1
导航: 论坛 -> 移动应用开发 斑竹:flyers,iamdream  
作者:
男 mp654kk (mp654kk) ▲△△△△ -
普通会员
2023/10/11 15:36:18
标题:
请问有没有办法获取combobox下拉列表当前第一个显示项 浏览:663
加入我的收藏
楼主: 比如combobox有很多元素,鼠标滚动了几秒,能不能获取当前列表里最上面那个元素的编号,谢谢.
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/10/13 23:44:57
1楼: Do you mean, get the first visible item in the list?  

It may be necessary to check the scroll value and perform a calculation based on the height of the items, so I think you can know which item is at the top of the combobox window based on the scroll position, height of the item (if they all have the same height), considering the height of the visible window.  did you understand?
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 mp654kk (mp654kk) ▲△△△△ -
普通会员
2023/10/14 1:23:06
2楼: @emailx45 Yes, can the scrolling value be obtained?
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/10/14 2:27:51
3楼: as said before, in a "class" exists many others hided... 
short answer: YES!
long answer: needs hack

ComboBox has a TListBox -> TListBox has ScrollBar object
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 mp654kk (mp654kk) ▲△△△△ -
普通会员
2023/10/15 18:47:21
4楼: @emailx45 Thanks,is this how to get it? This is written by ChatGPT. Why is it reporting an error?
uses
  FMX.ListBox, FMX.Types;

procedure GetVerticalScrollBarPosition;
var
  ListBox: TListBox;
  ScrollBar: TVertScrollBox;
  ScrollPosition: Single;
begin
  ListBox := ListBox1; 
  ScrollBar := ListBox.FindStyleResource('vscrollbar') as TVertScrollBox;
  if Assigned(ScrollBar) then
  begin
    ScrollPosition := ScrollBar.Value;
    ShowMessage('Vertical Scroll Position: ' + FloatToStr(ScrollPosition));
  end;
end;
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/10/16 7:09:59
5楼: try this:

   xxxxx AS TScrollBar....  or  TScrollBar( xxxx ).Value....

var
  O : TFmxObject;
begin
  O := xxxx.FindStyleResource ......
  if ( O <> nil ) and ( O is TScrollBar) then
     TScrollBar( O ).Value ....
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 mp654kk (mp654kk) ▲△△△△ -
普通会员
2023/10/16 13:02:10
6楼: @emailx45 谢谢 改成这样就可以了
procedure TForm1.Button1Click(Sender: TObject);
var
  ScrollBar: Tscrollbar;
  id: Integer;
begin
  ScrollBar := ListBox2.FindStyleResource('vscrollbar') as Tscrollbar;
  ShowMessage(ScrollBar.Value.ToString());
end;
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行100.0977毫秒 RSS