Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Collegue
Collegue el 27 de Mzo. de 2017
Comentada: Steven Lord el 28 de Mzo. de 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)

Respuesta aceptada

Image Analyst
Image Analyst el 27 de Mzo. de 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 comentarios
Collegue
Collegue el 28 de Mzo. de 2017
Thank you! it works!
Steven Lord
Steven Lord el 28 de Mzo. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Preprocessing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by