Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Collegue
Collegue le 27 Mar 2017
Commenté : Steven Lord le 28 Mar 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)

Réponse acceptée

Image Analyst
Image Analyst le 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 commentaires
Collegue
Collegue le 28 Mar 2017
Thank you! it works!
Steven Lord
Steven Lord le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Preprocessing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by