How to determine child row

Posted by: john-shugart on 8 September 2017, 1:00 pm EST

  • Posted 8 September 2017, 1:00 pm EST

    I have an Hierarchy grid and I have a context menu associated with it. When the user right-clicks on a parent row, I can determine the active row, but when the user right-clicks on a child row, I am unable to determine which child row it is.


    Can you tell me how I can tell what child row is active when the user right-clicks?


    Thanks in advance,


    John

  • Replied 8 September 2017, 1:00 pm EST

    Bob,


    That property doesn't seem to work correctly. If I click and expand parent 2, then click and expand parent 4, and click on a child for parent 2, the e.View.Parent.ActiveRowIndex is still set the the last parent I clicked on. Which in this case isn't the correct one.


    Is there another way to get the parent from the child row?


    Thanks in advance,


    John

  • Replied 8 September 2017, 1:00 pm EST

    John -

    In the CellClick event the e.Row property should return the active row for either the parent or the child.
  • Replied 8 September 2017, 1:00 pm EST

    Thanks Bob,


    If I am on a child row, is there a way I can access the parent row?


    John

  • Replied 8 September 2017, 1:00 pm EST

    You should be able to use the e.View.Parent in the CellClick event.
  • Replied 8 September 2017, 1:00 pm EST

    John -

    I would consider that the correct behavior.  The last row you clicked on in the parent was 4, which is the active row.  Clicking on a cell in the child will not change the active row in the parent.
  • Replied 8 September 2017, 1:00 pm EST

    John,


    Use the following code instead to get the index you are looking.


      e.View.ActiveSheet.ParentRowIndex

  • Replied 8 September 2017, 1:00 pm EST

    John -

    Scott is correct and I apologize for misunderstanding what you were trying to determine.  However, there is no ActiveSheet in the e.View property so the following should work for you...

    Private Sub FpSpread1_CellClick1(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles FpSpread1.CellClick
    If e.Button = Windows.Forms.MouseButtons.Right Then
    Dim i As Integer = e.View.ActiveSheetIndex
    MsgBox(e.View.Sheets(i).ParentRowIndex)
    End If
    End Sub
  • Replied 8 September 2017, 1:00 pm EST

    Thanks Bob,


    That was exactly what I needed!


    You guys ALWAYS come thru, and I do appreciate it!


    Thanks again,


    John

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels