Support has confirmed this is currently not possible. They might consider adding this functionality in a future release.
How can I change the visible limits of uidatepicker?
4 次查看(过去 30 天)
显示 更早的评论
When using the datepicker component in AppDesigner I want to set the limits which each component presents to the user. In particular I want to be able to choose the year from a greater range than 40 years, which seems to be the default no matter what limits are set, when creating the datepicker component.
See this example:
function mydateapp
f = uifigure('Position',[340 400 415 300]);
d = uidatepicker(f,'DisplayFormat','MM-dd-yyyy',...
'Position',[130 190 150 22],...
'Value',datetime(2000,1,1),...
'Limits', [datetime([1960, 1, 1]), datetime([2040, 1, 1])],...
'ValueChangedFcn', @datechange);
end
回答(1 个)
Abhipsa
2025-1-30
Hi, I get that you want the dropdown to show the years from “1960” to “2040”, but it’s showing a range of only 40 years. I am able to reproduce the issue in MATLAB R2024b and R2018b.
You can use this workaround that I have verified in 2024b and 2018b.
If you select any extreme value (highest or lowest) present in the given selection, then the dropdown gets extended up to next 40 years (depending on the values that has been selected).
The "Limits" parameter functions correctly, preventing selection beyond the specified bounds by crossing out the dates that are out of bound.

You can use "doc uidatepicker” command in your MATLAB command window to access the official documentation for “uidatepicker”.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!