当右键单击日历并运行功能区操作时,是否可以像获取当前邮件项或约会项一样获取选定的日历日期?
功能区 XML:
<contextMenu idMso="ContextMenuCalendarView">
<menu id="CallenderMenu" label="Actions">
<button id="NewDiaryEvent" label="Create new" onAction="CreateCallenderItem_click" />
</menu>
</contextMenu>
C#:
public void CreateCallenderItem_click(IRibbonControl control)
{
// Get selected calendar date
}
德米特里是正确的,但这里是我用来获取您所选区域的开始和结束日期的代码示例:
public void CreateCallenderItem_click(IRibbonControl control)
{
// Get selected calendar date
Outlook.Application application = new Outlook.Application();
Outlook.Explorer explorer = application.ActiveExplorer();
Outlook.Folder folder = explorer.CurrentFolder as Outlook.Folder;
Outlook.View view = explorer.CurrentView as Outlook.View;
if (view.ViewType == Outlook.OlViewType.olCalendarView)
{
Outlook.CalendarView calView = view as Outlook.CalendarView;
DateTime calDateStart = calView.SelectedStartTime;
DateTime calDateEnd = calView.SelectedEndTime;
// Do stuff with dates.
}
}
我希望这对您有更多帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)