How to delete a row in NSTableView on click of a button inside the column

JudefJudef AEMember
edited April 2016 in Xamarin.iOS

Hello,

I am working on Xamarin for Mac and did a table view as suggested in the help article for Xamarin here. We have three columns and third is a button column. How can we delete a row in the NStableview based on click of the button inside the third column. Any help would be greatly appreciated.

Tagged:

Best Answer

Answers

  • KMullinsKMullins USMember, Xamarin Team Xamurai

    Hi @judef,

    That is a great question (that I unfortunately don't know the answer to off the top of my head)! I'll take a look at the sample app and figure out how to get that working first thing Monday. I'll also add what I discover to the Mac docs and sample gallery.

    Please let me know if you need anything else.

    Thanks,

    Kevin

  • KMullinsKMullins USMember, Xamarin Team Xamurai

    All,

    For a quick update, I've modified the Working with Table Views documentation and included a section on Adding a Delete Button to a Row.

    Again, please let me know if there are any questions.

    Thanks,

    Kevin

  • JudefJudef AEMember

    Thank you very much Kevin, it helped a lot. Xamarin rocks!

  • GregCadmesGregCadmes USUniversity ✭✭

    @KMullins
    Thank you for the great TableView's Mac Sample.

    I've converted it to use Data Binding and Key-Value coding from this Xamarin example.
    Adding and removing an item from a collection is handled via the Key-Value coding, so far so good.

    My problem I'm having is not knowing how to add an action for when a row is double-clicked. I'd like to invoke my RelayCommand action.

    By chance would you be able to point me in the right direction?
    thanks much,

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai
    edited November 2017

    @GregCadmes

    There is a DoubleAction property on a NSTableView that holds a Selector, so try the following:

    tableView.DoubleAction = new Selector("doubleTapped:");
    
    [Export("doubleTapped:")]
    public void DoubleTapped(NSTableView sender)
    {
        Console.WriteLine($"Double Tapped Row {sender.ClickedRow}, Column {sender.ClickedColumn}");
    }
    
Sign In or Register to comment.