Fill editfield text value with string from a table

What I need to do is to read data from a csv like the one I have updated and then fill an edit field in app designer with what is written in that csv file.
As example i updated one with just a simple text in it.
I have tried with something like
DataComments = readtable('file7.csv');
app.CommentsEditField.value = DataComments
but it doesn't work.

回答 (1 件)

Les Beckham
Les Beckham 2023 年 6 月 8 日

0 投票

For this specific example, readlines might work better than readtable.
DataComments = readlines('file7.csv')
DataComments = 3×1 string array
"Comments" "testo di prova" ""
Then pick which one of these three strings you want to use to fill in your EditField. For example:
app.CommentsEditField.value = DataComments(2);
disp(app.CommentsEditField.value)
testo di prova

4 件のコメント

Massimo
Massimo 2023 年 6 月 9 日
Ok, thanks for the answer. In the meantime I have discovered it's better (for my purpose) using text area instead of an edit field text, but I have to still make some tests, so I'll eventually add infos to this post.
I'd ask you also another thing. Is it possible doing the same thing with a drop down menu? I'm trying to achieve this: reading an info as the one contained in a csv file (like the one i posted before), read that string and make it appear as value in the drop down menu.
Les Beckham
Les Beckham 2023 年 6 月 9 日
編集済み: Les Beckham 2023 年 6 月 12 日
You are welcome.
Once you read the string from the text file, you can do whatever you like with it.
If the answer helped you solve your issue, I would appreciate it if you click "Accept this Answer". Thanks.
Massimo
Massimo 2023 年 6 月 12 日
Ok, thank you. I have tried to make it work with a drop down menu, but it doesn't work. It goes in conflict with item data of drop down menu.
Les Beckham
Les Beckham 2023 年 6 月 12 日
If you want help with that issue, you are going to need to provide your app designer code and any data needed to run it (or a stripped down version of it that illustrates the issue).

サインインしてコメントする。

質問済み:

2023 年 6 月 8 日

編集済み:

2023 年 6 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by