Create Editable Table rows by selecting item number in ListBox in App Designer

5 ビュー (過去 30 日間)
Shashank K
Shashank K 2022 年 3 月 29 日
回答済み: Prasanna Konyala 2022 年 4 月 1 日
I have created a table with 8 rows and ListBox with 10 numbers in App Designer. Now I want to have a editable table rows ny selecting ListBox Item number. For example, if I click on 6 in ListBox item, 6 rows should be activated in Table with editable cells for data entry.
Done Following code but it throws error on command : for i=(nn+1):Nrows.
stiffness = get(app.UITable,'Data');
sz=size(stiffness);
Nrows=get(app.IsolatorsListBox,'Value');
Ncolumns=8;
set(app.UITable,'Data',cell(Nrows,Ncolumns));
nn=min([sz(1) Nrows]);
for i=1:nn
data_s{i,1} = stiffness{i,1};
data_s{i,2} = stiffness{i,2};
data_s{i,3} = stiffness{i,3};
data_s{i,4} = stiffness{i,4};
data_s{i,5} = stiffness{i,5};
data_s{i,6} = stiffness{i,6};
data_s{i,7} = stiffness{i,7};
data_s{i,8} = stiffness{i,8};
end
for i=(nn+1):Nrows %(error:For colon operator with char operands, first and last operands must be char.)
data_s{i,1} = '';
data_s{i,2} = '';
data_s{i,3} = '';
data_s{i,4} = '';
data_s{i,5} = '';
data_s{i,6} = '';
data_s{i,7} = '';
data_s{i,8} = '';
end

回答 (1 件)

Prasanna Konyala
Prasanna Konyala 2022 年 4 月 1 日
Hi Shashank
From my understanding it looks like Nrows is char and nn is number. That is why first loop ran without errors but second didn’t. Also, the above approach becomes complex and repetitive as you increase table size/list box size. There is an alternative solution for your desired functionality.

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by