Edit properties of a Work Item with API
If you look at the previous post, I answered a little problem that can occur when saving a Work Item in TFS with API. A common question that arise from people when they begin to work with the WIT api is how can I make possible for users of my application to edit a WIT? A Work Item has a lot of fields and building an UI to permit editing capabilities to the user would be really difficult, but clearly Microsoft has made the standard one available to use within your program.
The answer is the * Microsoft.TeamFoundation.WorkItemTracking.Controls.dll *located into C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies folder. This dll contains common winform controls to edit workitem and it has everything you need to create an UI to edit a Work Item. First of all create a simple winform application, then right click into the Toolbox and choose Choose Items option, then browse to the aforementioned dll and include it in the toolbox. Now you should be able to see the controls inside the dll
I highlighted the WorkItemFormControl, because you can use to edit a workitem, simply drop one instance into a simple form and write this code behind in the Form Load event.
|
|
The code is really simple, connect to the server, create a new Work Item with the NewWorkItem method of the WorkItemType object and assign it to the Item property of the WorkItemFormControl windows control. Here is the form at run-time.
As you can see this is the standard form that you see in Visual Studio, and it is available to you with a very little effort.
Alk.