index > Team Foundation Server - Work Item Tracking > How to create AreaPath dropdown in winforms?

How to create AreaPath dropdown in winforms?


Hello all!

When creating a new bug in Team Explorer, you have an Area: field that holds a nice dropdown that includes a look-a-like treeview. I believe the type is called "TreePath". Anyway...I'm currently creating a winform application and would like to re-create this Area dropdown.

For example purposes, when creating a bug in VSTS, the Area field looks like this:
Vince Test Project
-item 1
-item 2
-item 3

So far I've manage to do the following inside my winform application:

NOTE: _store.Projects[9]...project 9 is the ID of the project I'm interested in. Its hardcoded for now

Begin form_load
---------------------------------------------------------------------------
_store = (
WorkItemStore)_currentTFS.GetService(typeof(WorkItemStore));
WorkItemTypeCollection workItemTypes = _store.Projects[9].WorkItemTypes;
WorkItemType wit = workItemTypes["Sprint Backlog Item"];
WorkItem wi = new WorkItem(wit);

//Fill in the Area combobox
//GetArea(wi);

//Fin in the Build combobox
GetBuilds(wi);

//Fill in the Severity combobox
GetSeverities(wi);
---------------------------------------------------------------------------
End form_load


I have 3 combobox on my winform. One for replicating the Area field, another one for the Builds and one for the Severity.

The GetBuilds(wi) and GetSeverities(wi) procedure has the following code:

private void GetSeverities(WorkItem wrkitem)
{
//Load Severity combobox
foreach (string val in wrkitem.Fields["Conchango.VSTS.Scrum.Severity"].AllowedValues)
{
_cboSeverity.Items.Add(val);
}
//Default Severity combobox to first item
_cboSeverity.SelectedIndex = 0;
}

NOTE: The procedure for the GetBuilds() is the same except the .Fields[""] is not the same.

My question is the following, how can I programatically create the exact same dropdown field as the Area field?
When I debug the application and look at the CoreField.AreaPath, it returns the top level string Vince Test Project.

But what about the sub-items?
-item 1, -item 2, -item 3

When trying: wi.Fields[CoreField.AreaPath].AllowedValues.Count it returned "0" Why? I know I should be having a list because opening a bug and clicking the Area dropdown gives me:
Vince Test Project
-item 1
-item 2
-item 3

If anyone could help me figure out how to re-create the Area dropdown with all its sub-items that would be great! perhaps a link, example! anything!
Thanks in advance
Sincerely

Vince

Vlince

Vince, as you mentioned, there are two parts to this:

- Building dropdown tree control: Doing this is much simpler with VS2005 because of new controls that can make showing any control as dropdown of combobox easy with just few lines of code. I don't remember the links for that right now but you might able to find it in search - let me know if you cannot find it. Alternatively you can use older winforms features to build one and an example library is here: http://www.codeproject.com/cs/miscctrl/customcombos.asp?df=100&forumid=15223&exp=0&select=1493352 . After building it, you can use custom control features in SP1 beta to implement IWorkItemControl and host it in work item form.

- Getting tree data: Allowed values won't have the values because it is of tree data structure. You can read it from AreaRootNodes and IterationRootNotes properties of a project object (in your example _store.Projects[9] object). Each Node object has children collection that you can traverse through recursively and add those values to tree control you build above.




http://blogs.msdn.com/narend
Naren Datha - MSFT

Thank you Naren!

I've looked at the example (link) you gave me and this looks fairly complicated as oppose to your other suggestion, to "make showing any control as dropdown...with just a few lines of code". I'd be interested in seing an example using .NET 2.0.

I'm not sure I fully understand, is a TreeView control that you turn into a combobox **or** is it a combobox that holds a treeview?

Meanwhile, I did manage to loop trhough the AreaRootNodes and fill-in a regular combobox for now...

I have to admit, googling a bit I did found examples in VS 2003 and converted them into a VS 2005 project only to realize that people are really tweeking things. If there's no other/simpler way to do it, then I'll use one of the custom control.

If on the other hand, you could provide me an example of this "making showing any control as dropdown...with just a few lines of code" then perhaps I'd understand better.

Unfortunatelly, looking at the TreeView control and combobox, didn't manage to find the magical property "Turn into dropdown" hehehe...too bad I guess

Thanks again for the help Naren!
Sincerely

Vince

Vlince
Here is link to code to create treeview in a dropdown: http://blogs.msdn.com/jfoscoding/archive/2005/03/03/384430.aspx . The author says he did it in 20 mins, so it is easy with Whidbey ToolStripDropdown control.


http://blogs.msdn.com/narend
Naren Datha - MSFT
reply 4

You can use google to search for other answers

 

More Articles

Customizing Project Alerts
Display fullpath with filename in the WIT history
Limit Assignedto users depending on state.
Large number of queries
Bug -> Details -> Found in build
Handling simultaneously WorkItemChanged Events
iteration milestone dates - report
The tool lets you to add hyper links to work items in Microsoft W...
How can 2 dev teams work on the same projects.
Http error when adding attachments to work items
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

Access is denied: Could not create metad…
The Work Items node has a Red x
getting associated changesets for work i…
Inbox like query ?
ActivatedDate field definition problem
There is a way to delete/remove from ex…
Changes are not shown in the Form
Prohibiting a user from reviewing their …
Each rows in different color in VSTS can…
Limit Assignedto users depending on state.
Open source control
Organizing Projects into Products or Cus…
Deleting Work Items
Found In Build list too long
Cannot Open Microsoft Project

Hot Articles

Customizing Team Explorer
Can I Add a Customized Field Type for Wo…
Using Excel as bug template
Unable to publish start/finish dates and…
How can I know who's link to my WI??
Assigned To getting blanked out when clo…
help with wiqlQuery
Work Item rule change works ... most of …
About Work Items
Work Item automated email
File Attachment Best Practice
Used witimport and now getting 'Item has…
Comparing fields of a Work Item when fil…
Importing existing tasks into the new Te…
Assigning same task to multiple resources

Recommend Articles

WSS issue list and TFS Work Items, any i…
Custom alerts and inability for Daily/We…
Office table Pivot
Searching Work item history
Workflow items: First required then read…
Actions and fields of work items
Error: There may be problems with the wo…
How to delete previously imported items …
Apply column options to multiple queries
Bulk update using MS Excel is very slow
WorkItemTracking error : The INSERT stat…
Http error when adding attachments to wo…
Incorrect results view due to COPY rule
TFS RC: Error loading Microsoft.TeamFoun…
Prohibiting a user from reviewing their …