Firemonkey Grid Control - 禁用列移动;但允许调整列大小

发布于 2025-01-06 15:40:41 字数 261 浏览 1 评论 0原文

我在 FM 中使用 TGrid,希望用户能够调整列的大小,但不能重新组织列(即拖动和移动列标题)。我尝试更改许多公开的属性(“Locked”、“DragMode”、“EnableDrag”等...) - 但似乎没有任何效果达到预期效果?

真实的 FM 体验;我猜测我可能必须重写该类并更改后端结构的某些内容;但我不确定什么/在哪里 - 或者即使这是可行的?

明智的样本来源;如果您简单地添加一个 TGrid、添加几列并运行,您就会看到该问题。

非常感谢。伊恩.

I am using the TGrid in FM and want users to be able to resize a column, but not re-organise the columns (ie. drag & move the column header). I have tried changing many of the exposed properties ("Locked", "DragMode", "EnableDrag" etc...) - but nothing appears to have the desired effect?

In true FM experience; I am guessing that I may have to override the class and change something at the back-end structure; but am unsure what/where - or even if this is feasible?

Sample source wise; you can see the issue if you simply add a TGrid, add a few columns and run.

Many thanks in advance. Ian.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你列表最软的妹 2025-01-13 15:40:41
type
  TCustomGridHelper = class helper for TCustomGrid
  public
    /// <summary>
    /// Publish private FHeader from FMX.Grid.TCustomGrid.
    /// </summary>
    function _GetHeader: THeader;
  end;

function TCustomGridHelper._GetHeader: THeader;
begin
  Result := Self.FHeader;
end;

procedure TForm1.Grid1ApplyStyleLookup(Sender: TObject);
var
  I: Integer;
  Header: THeader;
  HeaderItem: THeaderItem;
begin
  Header := Grid1._GetHeader;
  for I := 0 to Header.ChildrenCount - 1 do
  begin
    HeaderItem := Header.Children[I] as THeaderItem;
    HeaderItem.DragMode := TDragMode.dmManual;
  end;
end;
type
  TCustomGridHelper = class helper for TCustomGrid
  public
    /// <summary>
    /// Publish private FHeader from FMX.Grid.TCustomGrid.
    /// </summary>
    function _GetHeader: THeader;
  end;

function TCustomGridHelper._GetHeader: THeader;
begin
  Result := Self.FHeader;
end;

procedure TForm1.Grid1ApplyStyleLookup(Sender: TObject);
var
  I: Integer;
  Header: THeader;
  HeaderItem: THeaderItem;
begin
  Header := Grid1._GetHeader;
  for I := 0 to Header.ChildrenCount - 1 do
  begin
    HeaderItem := Header.Children[I] as THeaderItem;
    HeaderItem.DragMode := TDragMode.dmManual;
  end;
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文