read datagrid cell when clicked RRS feed

  • Question

  • I have a powershell script I am writing with an xaml gui. In that script I have a datagrid that I am populating as a history. I want a function to run when a cell is clicked to get the content of that cell and search for it.

    the code I am trying to run is

    $HistoryGrid.Add_CellMouseClick({if ($_.button -eq 'Left'){HistoryClick}})

    however i get the following Error for that code

    At C:\<removed>\editing-PSResetUtility.ps1:141 char:1
    + $HistoryGrid.Add_CellMouseClick({if ($_.button -eq  'Left'){HistoryCl ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

    i based that line of code off https://stackoverflow.com/questions/31284508/powershell-datagridview-cell-click-event and another page that i cant find again.

    any suggestions on what I am missing would be appreciated.

    Thursday, June 13, 2019 11:27 PM

All replies

  • Sorry but there is not enough information to determine your issue.

    Are you a programmer?  Have you been trained in WPF?  Do you understand the mechanism for binding PS code to a control event?  Have you added this event to the XAML for your form?


    Friday, June 14, 2019 1:03 AM