Search code examples
matlabmatlab-uitable

Getting selected cell indices from uitable


I have a uitable with 10 columns, which I'm populating from a db.

Now I want to know when the user choose a specific row. For example if the user chooses the 3rd record, I would like to get back the value 3, so then I could access the actual information to for example open that specific record from the path.

I found online that I would need findjobj. I also think that the method should be implemented in here:

function uitable_CellSelectionCallback(hObject, eventdata, handles)

However I found a little information about how I should proceed.

Anyone had this problem or knows how to solve it?


Solution

  • When calling the CellSelectionCallback you can access the Indices property, which is a 2 x 1 array containing the row and column indices of the cell you have selected.

    Therefore in your callback, use something like this:

     row = eventdata.Indices(1)
     col = eventdata.Indices(2)
    

    and that should get you going.