组合框的时间到下一个30分钟像Outlook [英] Combo box of time to the next 30 minutes like Outlook

查看:82
本文介绍了组合框的时间到下一个30分钟像Outlook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



如何让组合框显示当前索引或当前值或当前文本到接下来的30分钟,就像outlook选择新会议的时间一样?我有一个修复组合框收集从凌晨12点,上午12点半,凌晨1点到晚上11点30分,如全天时间。



组合框默认情况下,开始时间是最近的30分钟。



- 如果PC时间是上午9:35,它将自动选择到上午10:00。

- 如果PC时间是上午10:00,它将自动选择到上午10:30。



如下图所示链接

http://www.ljmu.ac.uk/ITHelp/ITHelp_Images/OutlookNewAppointment。 png [ ^ ] < br $>


编辑

**我需要一个在组合框上编码的链接



TQ

Hi all,

How to make a combobox showing the current index or current value or current text to the next 30 minutes just like outlook selecting time for new meeting? I have a fix combobox collection starting 12:00 AM, 12:30 AM, 1:00 AM to 11:30 PM like full day time.

Where combo box "Start Time" by default is nearest next 30 minutes.

- If the PC time is 9:35 AM, it will automatically select to 10:00 AM.
- If the PC time is 10:00AM, it will automatically select to 10:30 AM.

As picture from below link
http://www.ljmu.ac.uk/ITHelp/ITHelp_Images/OutlookNewAppointment.png[^]

Edited
** I need a link to code this on combobox

TQ

推荐答案

// It's a function for rounding up or down by a minute interval
public static DateTime Round(DateTime dt, int dir, int interval)
{
	// dir 1 = up, dir 0 = down
	DateTime t;
	if (dir == 1)
		t = dt.AddMinutes((60 - dt.Minute) % interval);
	else
		t = dt.AddMinutes(-dt.Minute % interval);
	return t;
}





对于StartTime,您将使用:





For the StartTime, you will use:

DateTime startTime = Round(Now, 1, 30);





对于第二个组合框,您将使用:





For the second combobox, you will use:

DateTime nextTime = startTime.AddMinutes(30);


这可能帮助你..





DateTime.AddMinutes [ ^ ]
this might help you..


DateTime.AddMinutes[^]


这篇关于组合框的时间到下一个30分钟像Outlook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆