2016-01-22 109 views
0

VS2012 TFS2012TFS构建定义下拉菜单

我跟着this简单的指导,以创建构建定义下拉菜单。我的目标是有两个下拉菜单,一个有20个选项,可以选择多个选项,其次是70,然后选择一个。

添加两个以上的枚举选项后,选择和取消选择无法正常工作。例如:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace Workflow.ActivityHelpers 
{ 
public enum Enums 
    { 

     Internal, 
     Public, 
     Failed, 
     Another, 
     YetAnother 
    } 
} 

我选择Another和Internal取消选择,并选择Public和Failed。每次点击,我都会获得所选\未选择选项的不同组合。

编辑: 将图片 打开下拉 只有Internal2选择(太低代表发布超过2个链接) 点击了另一个 link 现在3被选中。

请参阅其他帖子的答案。

+0

你能提供的下拉菜单屏幕截图?工作不正常的细节现象是什么?你想使用多选还是单选? –

+0

一个有20个选择,并且能够选择多个选项,其次是70并且只选择一个。 – Claudius

回答

0

我到底是什么了做是这样的: custom type for an argument

我需要得到数据的XML。对于多选,我使用了从xml部分创建的动态复选框。对于单选,我使用了组合框。

重要说明。要真正做到这一点工作,并建立读取数据U需要更改

返回值;

class CredentialEditor : UITypeEditor 
{ 

    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) 
    { 
     string selected = null; 
     if (provider != null) 
     { 
      IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); 

      if (editorService != null) 
      { 
       Credential credential = value as Credential; 

       using (CredentialDialog dialog = new CredentialDialog()) 
       { 
        dialog.UserName = credential.UserName; 
        dialog.Password = credential.Password; 

        if (editorService.ShowDialog(dialog) == DialogResult.OK) 
        { 
         credential.UserName = dialog.UserName; 
         credential.Password = dialog.Password; 
         selected = dialog.UserName 
        } 
       } 
      } 

     } 

     return new Credentials() { UserName = selected}; 

    } 
0

本指南使用“if ... then ... else”。这适用于两种选择。请更改为正确的代码。并确保可以支持多种选择的变量类型。

+0

我应该说之前,我不使用If语句。所有我想要的是得到选择枚举当构建是运行。我做了不同的方式。请参阅帖子。 – Claudius