2016-01-22 117 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