Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TElXTree: how do i read the celltext on mousemove

Hello LMD Team,

I would like to use the procedure OnMouseMove from TElXTree to display the CellText under the cursor in a label.
With HitColumn I get the column, how do I get the cell (or row)?

Thank you very much for your help
Best regards

Gerd Scholz

Comments

  • 5 Comments sorted by Votes Date Added
  • You can use GetItemAt method.
  • edited December 2023 Posts: 10Vote Up0Vote Down

  • edited December 2023 Posts: 10Vote Up0Vote Down
    Hi Eugene,

    Thanks for your answers, also thanks for the answer to my first question about the TElXTree component!!!

    II have tried to work with GetItemAt(X, Y, ItemPart, HitColumn). I don't understand all the parameters in the procedure.  So I can only use the column (HitColumn), I am missing the value for the cell

    I need something like this:

    Label1.Caption:= Items[HitColumn].Cells[Row].Text

    And what can I do with ItemPart?

    This is my test procedure:
    procedure TFMain.ElXTree1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
      Integer);
    var
      Item: TElXTreeItem;
      ItemPart: TSTXItemPart;
      HitColumn, i: Integer;
    begin
      Item := ElXTree1.GetItemAt(X, Y, ItemPart, HitColumn);
        Label1.Caption := IntToStr(x) + ' ' + IntToStr(y) + ' ' + IntToStr(HitColumn);
        if HitColumn > -1 then
        begin
          Label2.Caption := ElXtree1.items[hitcolumn].Text;
        end;
    end;




    and I have another question about the Headerlayout
    I have two rows in the header, in the second one I want to display some icons 
    With 
    ATree.Header.Rows[0].Cell[2].Join(1, 4);
     ATree.Header.Rows[0].Cell[6].Join(1, 3);
    I Join the Header Sections
    If the headers are joined, then I get the icon for the lower row also in the upper joined cell. I only need the icons in the second row.
    See the md.png

    Thanks for the help
    PNG
    PNG
    lmd.PNG
    7K
  • Just ignore unneeded parameters and use returned Item:

    procedure TFMain.ElXTree1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
      Integer);
    var
      Item: TElXTreeItem;
      ItemPart: TSTXItemPart;
      HitColumn, i: Integer;
    begin
      Item := ElXTree1.GetItemAt(X, Y, ItemPart, HitColumn);
      if Item <> nil then
        Label2.Caption := Item.Text;
    end;
  • > I have two rows in the header, in the second one I want to display some icons

    Unfortunately this cannot be done. All header cells (on all rows), which correspond to a header section will use the section's image.
Sign In or Register to comment.