Filter löschen
Filter löschen

How can I set my calendar date in an edit box?

2 Ansichten (letzte 30 Tage)
Collegue
Collegue am 27 Mär. 2017
Kommentiert: Steven Lord am 28 Mär. 2017
I have this code and I want to choose a date from the calendr and after that display it in an edit box. However, I only can choose a date because after that, I can't see my choice in the edit box:
function pushbutton_cb_Callback(hObject, eventdata, handles)
f.Visible='off';
dateEditBoxHandle = uicontrol(f, 'Style', 'Edit', 'Position', [140 100 100 20], 'BackgroundColor', 'w');
uicalendar('Weekend', [1 0 0 0 0 0 1],'SelectionType', 1,'DestinationUI',dateEditBoxHandle,'OutputDateFormat','dd / mm / yyyy');
function dateEditBoxHandle_Callback(hObject, eventdata, handles)

Akzeptierte Antwort

Image Analyst
Image Analyst am 27 Mär. 2017
I haven't used uicalendar(). In fact I don't even have it. Maybe it's only R2017a and later - I don't know. But I can see you're using GUIDE so there is no need to call dateEditBoxHandle=uicontrol. You already have an edit text box control - I know because you showed the function line for its callback. And I don't know what f is. But if you need to pass in the edit box handle to uicalendar(), I'd think you might use the existing one rather than create a new one, but again, I haven't used uicalendar. So I'd try
uicalendar('Weekend', [1 0 0 0 0 0 1],...
'SelectionType', 1,...
'DestinationUI',
handles.dateEditBoxHandle,...
'OutputDateFormat','dd / mm / yyyy');
and see if that works. Note closely that I added "handles." before the handle (tag). And I got rid of f and the call to uicontrol.
  2 Kommentare
Collegue
Collegue am 28 Mär. 2017
Thank you! it works!
Steven Lord
Steven Lord am 28 Mär. 2017
Image Analyst, uicalendar is in Financial Toolbox which may explain why you don't have it. According to that documentation it's been in that toolbox since before release R2006a.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Preprocessing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by