필터 지우기
필터 지우기

How can I change statebutton value?

조회 수: 1 (최근 30일)
jiwon ham
jiwon ham 2019년 11월 21일
편집: Adam Danz 2019년 11월 23일
When I push button, I want to output my value on editfield.
And I did it, but I can't change my value when I pressed it again.
Here is my code,
app.Button_9.BackgroundColor = 'g'; %I want to change button's background color when I pressed it,
if sb.Value == 1;
app.EditField.Value = num2str(1)
else sb.Value == 0;
app.EditField.Value = num2str(2) %Actually, I want to reset the value when I pressed again, but I can't.
end
It means, I want to change my editfield value 1 to 0 when I pushed state button, and turn background color off.
Please help me
  댓글 수: 2
Adam Danz
Adam Danz 2019년 11월 21일
편집: Adam Danz 2019년 11월 23일
Try this
if sb.Value == 1;
app.Button_9.BackgroundColor = 'g';
elseif sb.Value == 0;
app.Button_9.BackgroundColor = [.5 .5 .5]; % or whatever the default color is
end
app.EditField.Value = num2str(sb.Value);
jiwon ham
jiwon ham 2019년 11월 23일
I've been struggling with it for a day, but I've solved it thanks to you.
Thankyou for your help :)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by