Popup menu in uitable - There is no String property on the Table class.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kelly Kyriakou
il 20 Set 2015
Commentato: Kelly Kyriakou
il 22 Set 2015
I have this code and when I want to switch cases with the following code
listliterature={'Kim and Feng (2003) - Longitudinal', 'Kim and Feng (2003) - Transverse',...
'Sextos,Koilanitis and Moschonas (2011) - Bilinear' ,'Sextos,Koilanitis and Moschonas (2011)- Trilinear'...
'Guo A. et al.(2014)- After 100 years','Guo A. et al. (2014) - After 90 years','Guo A. et al. (2014) - After 80 years'...
'Guo A. et al. (2014) - After 70 years','Guo A. et al. (2014) - After 60 years','Guo A. et al. (2014) - After 30 years'...
'Guo A. et al. (2014) - Sound', 'Neilson G.(2015) - Rix - MSC Concrete'};
popup_column2 = 2;
col_fmt = get(handles.uitable1, 'ColumnFormat');
col_fmt{popup_column2} = listliterature
set(handles.uitable1, 'ColumnFormat', col_fmt);
str = get(hObject, 'String');
switch str
case 1... etc
I have this error:
Error using matlab.ui.control.Table/get
There is no String property on the Table class.
Error in main5>uitable1_CellEditCallback (line 206)
str = get(hObject, 'String')
How can I solve this problem? Thank you in advance
0 Commenti
Risposta accettata
Walter Roberson
il 20 Set 2015
You need to set the column to be editable.
To retrieve you need to get the Data property of the table, index that at the appropriate cell, and look at the value there.
3 Commenti
Steven Lord
il 21 Set 2015
I think you might have missed the most important part of Walter's suggestion. UITABLE objects do not have a String property; they have a Data property that contains the table data.
If your data is stored in the Data property as a numeric array, your cases should also be numeric. If your data is stored as a cell array containing strings, your cases should be strings. You can actually include both in the same case or include them in separate cases, as appropriate:
for k = {1, '1', 2, '2'}
x = k{1}; % First x will be the number 1, then the string '1', etc.
switch x
case {1, '1'}
disp('X is a 1');
case {2}
disp('X is the number 2');
otherwise
disp('X is the string ''2''');
end
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!