How to select/highlight a cell/row in the uitable programmatically?

56 ビュー (過去 30 日間)
Vyshakh Pv
Vyshakh Pv 2018 年 8 月 20 日
編集済み: Adam Danz 2021 年 5 月 10 日
I am working with 3 big XLS files, each opened in 3 uitable. When i click on a cell of any of the uitable, row with matching time from other 2 tables should be highlighted.
If the row is not visible, _ uitable_ should scroll accordingly.
So, how to programmatically highlight a row or column of a uitable?
If it is impossible, is there any other solution to the problem??

採用された回答

Adam Danz
Adam Danz 2018 年 8 月 20 日
編集済み: Adam Danz 2021 年 5 月 10 日
Matlab R2021a and later
Starting in Matlab r2021a you can programmatically scroll to any row, column, or specific cell in a uitable using the scroll function (see Four New App Features in MATLAB R2021a).
To highlight parts of the uitable, use uistyle (R2019b and later);
Prior to Matlab R2021a
Here's an explanation of how to programmatically select a cell from a UI table.
The workflow you'll follow for your description is this
  • For each UItable, within the CellSelectionCallback, get the currently selected cell coordinates.
  • Within the same callback function, use those coordinates to set the other UI tables (see link above).
I'm not sure if this will automatically scroll or not, though. If you get stuck, follow-up with a comment below.
  5 件のコメント
Adam Danz
Adam Danz 2018 年 12 月 5 日
Thanks for the feedback, Vyshakh. I'm using matlab 2018a and when I select a row higher up in the table, the table jumps to that row as expected. I wonder if this is a difference in matlab versions or if there's something in your code causing that.
Matlab's findobj() function is not open source so I'm not sure how you found lots of pause() in that function. If you mean that the findobj() function takes too much time, you could set up your code so that the object is stored in a persistent variable so your code only has to find it once.
Vyshakh Pv
Vyshakh Pv 2019 年 5 月 2 日
  1. Error in Jumping to previous row due to my coding, its fixed and working fine now
  2. I was talking about findjobj() (mentioned in the link shared by you) not findobj().

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by