View.GoToDate(DateTime) 方法

定义

更改当前视图用来显示信息的日期。

public:
 void GoToDate(DateTime Date);
public void GoToDate (DateTime Date);
Public Sub GoToDate (Date As DateTime)

参数

Date
DateTime

应当将视图更改到的日期。

注解

若要在当前视图(如 对象)CalendarView中指定要转到的日期,应首先使用 CurrentView 而不是 获取View当前视图的 CurrentView对象。 下面的代码示例演示如何执行此操作。

Sub TestGoToDate()
    Dim oCV As Outlook.CalendarView
    Dim oExpl As Outlook.Explorer
    Dim datGoTo As Date

    datGoTo = "11/7/2005"

    ' Display the contents of the Calendar default folder.
    oExpl = Application.Explorers.Add( _
        Application.Session.GetDefaultFolder( -
        Outlook.OlDefaultFolders.olFolderCalendar), _
        Outlook.OlFolderDisplayMode.olFolderDisplayFolderOnly)
    oExpl.Display()

    ' Retrieve the current view by calling the 
    ' CurrentView property of the Explorer object.
    oCV = oExpl.CurrentView

    ' Set the CalendarViewMode property of the 
    ' current view to display items by day.
    oCV.CalendarViewMode = Outlook.OlCalendarViewMode.olCalendarViewDay

    ' Call the GoToDate method to set the date
    ' for which information is displayed in the view.
    oCV.GoToDate(datGoTo)
End Sub
private void TestGoToDate()
{
    Outlook.CalendarView oCV;
    Outlook.Explorer oExpl;
    System.DateTime datGoTo;

    datGoTo = DateTime.Parse("11/7/2005");

    // Display the contents of the Calendar default folder.
    oExpl = Application.Explorers.Add(
        Application.Session.GetDefaultFolder(
        Outlook.OlDefaultFolders.olFolderCalendar),
        Outlook.OlFolderDisplayMode.olFolderDisplayFolderOnly);
    oExpl.Display();

    // Retrieve the current view by calling the 
    // CurrentView property of the Explorer object.
    oCV = (Outlook.CalendarView)(oExpl.CurrentView);

    // Set the CalendarViewMode property of the 
    // current view to display items by day.
    oCV.CalendarViewMode = 
        Outlook.OlCalendarViewMode.olCalendarViewDay;

    // Call the GoToDate method to set the date
    // for which information is displayed in the view.
    oCV.GoToDate(datGoTo);
}

适用于