Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Sept. de 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 comentarios
Steven Lord
Steven Lord el 21 de Sept. de 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 el 22 de Sept. de 2015
Thank you both of you for your help! It was really precious!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by