필터 지우기
필터 지우기

Cycle trough handles on GUI

조회 수: 2 (최근 30일)
Lorenzo
Lorenzo 2013년 11월 6일
댓글: Lorenzo 2013년 11월 6일
Dear all, this is probably a stupid question and it was probably asked a thousand times before… Anyway… I have a GUI with a lot of tables. Every table's content is held by a handle called handle.table1, handle.table2 and so forth.
I would like to be able to change the content of the tables automatically with a for cycle.
So far I'm doing this: set(handle.table1, 'PropertyName', PropertyValue) set(handle.table3, 'PropertyName', PropertyValue) set(handle.table2, 'PropertyName', PropertyValue)
And I would like to do this:
for N=1:20
set(handle.tableN, 'PropertyName', PropertyValue)
end
But… how can I do it? I would like not to change the structure of the handle as that would be a messy solution since I have 4000 lines of code and would require a big rework of the whole GUI…
Thanks a lot!
Lorenzo

채택된 답변

Lorenzo
Lorenzo 2013년 11월 6일
That's great, thanks! I guess I'll ty and use eval in order to do that… That's something I've already done in the past but I wasn't sure if I could do that with handles as well…
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 11월 6일
You should not use the eval() option for what you want. Use the dynamic structure field name option.
for N=1:20
set(handle.(sprintf('table%d',N)), 'PropertyName', PropertyValue)
end
Or if you are setting the same thing for all of them, no loop is needed if you use
set([handle.table1, handle.table2, handle.table3, .....], 'PropertyName', 'Value');
Lorenzo
Lorenzo 2013년 11월 6일
I'm not setting the same thing for all of them. The first option you proposed (dynamic field) seems great! I'll test that!
Thanks for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 11월 6일

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by