简体   繁体   中英

VSTO MsProject get task duration as string as i see it on the screen

The default display unit of duration is hours. The task.Duration cell contains the value in minutes. How to get a value in hours into a variable? For example.

In display I see 5h

in variable Task.Duration = 300

me need

string s = Task.Duration;

s must be equal to 5

In the d variable, I need to get what I see on the screen, regardless of the value of the duration unit settings.

5*60 is not suitable. MsProject duration rounds up to integers. And the value after * may not match what is on the screen.

thanks

Sorry for my bad english.

The Duration property of the task object returns the value in minutes; use this to get the most precise answer. Alternatively, use the GetField method to return the displayed value (String). For example:

string taskDuration = task.GetField(188743709);

See this list of enumerated field constants .

Also try searching stackoverflow for similar questions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM