Howdy, Stranger!

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

In this Discussion

TElXTree: Using the keyboard to move to different cells: How to know which column is current?

Using the mouse one can in OnMouseDown use GetItemAt(X, Y, ...), but what if one is using the keyboard?

I need different actions depending on which column is active.

Thanks.
Raymond

Comments

  • 7 Comments sorted by Votes Date Added
  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Hi Raymond,

    thank you for ypur request. Strangely, here is no convenient property for this. I'll add such for next update, meanwhile you can use a workaround code like following:

      if ElXTree1.Selected <> nil then
        for I := 0 to ElXTree1.Selected.Cells.Count - 1 do
          if ElXTree1.Selected.Cells[i].Selected then
          begin
            Label1.Caption := inttostr(i);
            break;
          end;


  • Thanks.

    I created a function from this:

    function GetActiveColumn(const XTree : TElXTree) : Integer;
    var
      i : Integer;
    begin
      Result := -1;

      if XTree.ItemFocused = nil then
      begin
        Exit;
      end;

      with XTree.ItemFocused do
      begin
        for i := 0 to Pred(Cells.Count) do
        begin
          if Cells[i].Focused then
          begin
            Result := i;

            Exit;
          end;
        end;
      end;
    end;

  • I changed this before posting:

    if Cells[i].Focused then

    It should be:

    if Cells[i].Selected then

    Raymond


  • Hi Victor.

    Which property will you add for this - SelectedColumn?

    I can set the value of the selected column using SelectColumn, but SelectColumn is not updated by clicking on a cell that is in a different column.

    Should SelectColumn be updated upon a change?

    Raymond.


  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Hi Raymond,

    The property will be called HitColumn. 
    It will show currently selected (by mouse or keys) cell's column index.
    Regarding SelectColumn property. SelectColumn was intended to set column index programmatically and does not reflect selection changes made by mouse click and key press.

  • I have checked hitColumn.

    It works in cases where Cells[i].Selected has not changed.

    For example, when two fields are DateTime fields and the DateTime Inplace Editor is used, select and edit the 2nd field and then click on the 1st field's cell in the same row and edit that.

    In AfterOperation of the DateTime Inplace Editor, the value of Cells[i].Selected is not correct: it shows 1 and it should already have changed to 0.

    Thank you for adding the property HitColumn.

    Raymond
Sign In or Register to comment.