Problem with checkbox in Gui
古いコメントを表示
Hi,
I am creating a GUI that is having checkbox. I used the uicheckbox since everytime that I am running the gui the number of checkboxes will be changed. The program first read from a csv file and according to the rows in the csv file, the checkbox will be created so that user can choose from these checkboxes.
The problem is that when I am running the program out of gui it is working perfect and the checkbox is a matlab.ui.control.checkbox. But when I am using it inside the gui, it will be a double and I can not find which ones user selected.
Can anyone help??
9 件のコメント
Walter Roberson
2018 年 7 月 11 日
We will need to see your code.
Geoff Hayes
2018 年 7 月 11 日
Sara - why do you have a continue in your inner for loop. Won't this just create one checkbox for that column before exiting the inner loop and moving to the next column?
Please also clarify what you mean by .. I am running the program out of gui it is working perfect... What program are you running outside of the GUI? What is the double when running the code in side the GUI?
faran
2018 年 7 月 11 日
Walter Roberson
2018 年 7 月 11 日
When you are running it inside the GUI, is it possible that you are running it in R2014a or earlier?
faran
2018 年 7 月 11 日
Geoff Hayes
2018 年 7 月 11 日
Sara's answer moved here
I tried the uicontrol method too but still the output is a matrix!
Walter Roberson
2018 年 7 月 11 日
Inside the gui: is it possible the GUI is App Designer based?
... I think we are going to need the GUI code (and any .fig) to test with.
faran
2018 年 7 月 11 日
回答 (1 件)
Walter Roberson
2018 年 7 月 11 日
In testgui_OpeningFcn add the lines
global Target_checkbox
Target_checkbox = gobjects(0);
What is happening is that you are not initializing Target_checkbox, so by default it is initialized to [] which is a numeric array. When you assign a graphics handle into a double array, it automatically converts it to the old-style numeric handles.
6 件のコメント
faran
2018 年 7 月 11 日
Walter Roberson
2018 年 7 月 11 日
selected = cell2mat(get(Target_checkbox,'Value'));
faran
2018 年 7 月 11 日
Walter Roberson
2018 年 7 月 12 日
I tested it, and it will always return the values as they are at the time you run the line of code.
Devante Kerr
2021 年 8 月 12 日
Do you know if this samemethod would work for a property?
Walter Roberson
2021 年 8 月 12 日
Initializing to gobjects() would be useful for a property that will eventually be a graphics object.
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!