Effacer les filtres
Effacer les filtres

Popup menu in uitable - There is no String property on the Table class.

2 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Walter Roberson
Walter Roberson le 20 Sep 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 commentaires
Steven Lord
Steven Lord le 21 Sep 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
Kelly Kyriakou
Kelly Kyriakou le 22 Sep 2015
Thank you both of you for your help! It was really precious!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by