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

1 次查看(过去 30 天)
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)

采纳的回答

Image Analyst
Image Analyst 2017-3-27
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 个评论
Steven Lord
Steven Lord 2017-3-28
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Preprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by