OutputGroups.Item(Object) 方法

定义

返回 OutputGroup 集合中的对象 OutputGroups

public:
 EnvDTE::OutputGroup ^ Item(System::Object ^ index);
public:
 EnvDTE::OutputGroup ^ Item(Platform::Object ^ index);
EnvDTE::OutputGroup Item(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.OutputGroup Item (object index);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member Item : obj -> EnvDTE.OutputGroup
Public Function Item (index As Object) As OutputGroup

参数

index
Object

必需。 要返回的 OutputGroup 对象的索引。

返回

OutputGroup

一个 OutputGroup 对象。

属性

示例

public void CodeExample(DTE2 dte)  
{    
    try  
    {  
        // Open a project before running this example.  
        Project proj = dte.Solution.Projects.Item(1);  
        OutputGroups groups = proj.ConfigurationManager.ActiveConfiguration.OutputGroups;  
        int c = 1;  
        int x = 0;  
        string msg;  
        // Find the last outputgroup with at least one file.  
        foreach (OutputGroup grp in groups)  
        {  
            x++;  
            if (grp.FileCount > 0)  
                c = x;  
        }  
        OutputGroup group = groups.Item(c);  
        msg = "The " + c + "/" + groups.Count + " item in the OutputGroups groups collection is " +  
            group.DisplayName;  
        msg += "\nThe parent of the collection is the Configuration: " + groups.Parent.ConfigurationName;  
        msg += "\nThe application containing this collection is: " + groups.DTE.Name;  
        MessageBox.Show(msg);  
    }  
    catch(Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

注解

传递给的值 Index 是一个整数,它是 OutputGroup 集合中对象的索引 OutputGroups ,或者是一个字符串值,表示 OutputGroup 集合中对象的名称。

Item ArgumentException 如果集合找不到与索引值对应的对象,则该方法将引发异常。

适用于