关于ListBox的提示 ListBox每行的内容太长,但又不想显示水平滚动条,怎样可以做成以下这种效果:当鼠标停留在某项(没有点击)的时候就提示该项的内容?不是弹出对话框的那种提示,是hint 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以考虑用listview,它会提示 如果不想自行实现Hint,就用一个单列的ListView吧设成report风格,不显示行分隔线,效果和ListBox基本一样 另外还可以通过在OnMouseMove中,通过ListBox1.ItemAtPos(Point(x,y),True);获得鼠标位置的索引,然后显示其信息 procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);var pt: TPoint; nIndex, nWidth: integer; str: String;begin pt.X := X; pt.Y := Y; nIndex := ListBox1.ItemAtPos(pt, true); if nIndex > -1 then begin str := ListBox1.Items.Strings[nIndex]; nWidth := ListBox1.Canvas.TextWidth(str); if nWidth >= ListBox1.Width - 2 then begin ListBox1.Hint := str; Application.ActivateHint(ClientToScreen(pt)); end else begin Application.HideHint; ListBox1.Hint := ''; end; end else begin ListBox1.Hint := ''; Application.HideHint; end;end; 记住要:ListBox1.ShowHint := true; 根據mouse的point去Canvas出hint... 如何变成单列的?我搜了半天也没搜到如何设置ListView为单列显示 Application.ActivateHint(ClientToScreen(pt));去掉这句就更好,不然提示语句跑太远了 去掉 ClientToScreen,直接用pt就行了 取决于你的ListBox的父窗口是不是窗体。 stringgrid的一个小问题,同一列字如何换行 关于类型库中内存错误 关于ADO的,把EXCEL中的数据导入到SQL SERVER2000中....... Delphi7的注册和不注册有什么区别?有影响吗? 谁有客户管理系统源码 delphi中的事务处理? 高手们都过来看看,,Form的名称如何以变量的方式引入。 在线关注这样一个问题! Delphi 包的使用 关于数据库工具要输入用户名密码的问题 delphi中POPUPMENU如何右擊複製DBGRID選擇中的內容 delphi 自动编号的问题
设成report风格,不显示行分隔线,效果和ListBox基本一样
Y: Integer);
var
pt: TPoint;
nIndex, nWidth: integer;
str: String;
begin
pt.X := X;
pt.Y := Y;
nIndex := ListBox1.ItemAtPos(pt, true);
if nIndex > -1 then
begin
str := ListBox1.Items.Strings[nIndex];
nWidth := ListBox1.Canvas.TextWidth(str);
if nWidth >= ListBox1.Width - 2 then
begin
ListBox1.Hint := str;
Application.ActivateHint(ClientToScreen(pt));
end
else
begin
Application.HideHint;
ListBox1.Hint := '';
end;
end
else
begin
ListBox1.Hint := '';
Application.HideHint;
end;
end;
如何变成单列的?我搜了半天也没搜到如何设置ListView为单列显示
去掉这句就更好,不然提示语句跑太远了
取决于你的ListBox的父窗口是不是窗体。