How can I add information to a uitable by clicking a checkbox and take it out of the table by unclicking it?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Matthew Joyner
le 14 Avr 2017
Modifié(e) : Sindhu Priya
le 17 Avr 2017
I am trying to add values that are in a cell array (ex. {Category,Thing}) into a uitable by clicking the checkbox and take it out of the uitable by unclicking. I can't seem to figure it out.
0 commentaires
Réponse acceptée
Sindhu Priya
le 17 Avr 2017
Modifié(e) : Sindhu Priya
le 17 Avr 2017
Hi Matthew,
Please find the following code snippet, this creates a table and checkbox.
table = uitable;
uicontrol('Style','checkbox','String','Check Me','Value',0,'Position',[300 300 130 200],'Callback',{@checkBoxCallback,table,'Category','Thing'});
And the checkBoxCallback adds the row to the UI table when the check box is checked and removes the same when unchecked.
The checkBoxCallback is as follows,
function checkBoxCallback(hObject,eventData,table,category,category_value)
value = get(hObject,'Value');
if value==1
table.Data={category,category_value};
else
table.Data={'',''};
end
end
Hope this answers your query.
Regards,
Sindhu
0 commentaires
Plus de réponses (0)
Voir également
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!