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

1 view (last 30 days)
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)

Accepted Answer

Image Analyst
Image Analyst on 27 Mar 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 Comments
Steven Lord
Steven Lord on 28 Mar 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Preprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!