Share via


Command.AddControl 메서드

업데이트: 2007년 11월

명령에 대한 영구 명령 모음 컨트롤을 만듭니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

Function AddControl ( _
    Owner As Object, _
    Position As Integer _
) As CommandBarControl

Dim instance As Command
Dim Owner As Object
Dim Position As Integer
Dim returnValue As CommandBarControl

returnValue = instance.AddControl(Owner, _
    Position)
CommandBarControl AddControl(
    Object Owner,
    int Position
)
CommandBarControl^ AddControl(
    [InAttribute] Object^ Owner, 
    [InAttribute] int Position
)
function AddControl(
    Owner : Object, 
    Position : int
) : CommandBarControl

매개 변수

  • Owner
    형식: System.Object

    필수적 요소. 새 명령 모음 컨트롤을 추가할 Microsoft.VisualStudio.CommandBars.CommandBar 개체입니다.

  • Position
    형식: System.Int32

    선택적 요소. 명령 모음에서 1부터 시작하는 새 컨트롤을 배치할 인덱스 위치입니다.

반환 값

형식: Microsoft.Office.Core.CommandBarControl

Microsoft.VisualStudio.CommandBars.CommandBarControl 개체입니다.

설명

추가 기능이 로드되는지 여부에 관계없이 명령의 ContextUIGUID 또는 QueryStatus Method에 대한 응답에 따라 환경의 새 세션이 실행될 때마다 컨트롤을 사용할 수 있도록 컨트롤 및 컨트롤 위치가 환경에 저장됩니다.

예제

' Macro code.
Imports Microsoft.Office.Core
Sub AddControlExample()
   ' Before running, you must add a reference to
   ' Microsoft.VisualStudio.CommandBars. Also, 
   ' for this example to work correctly, there should be an add-in 
   ' available in the Visual Studio environment.
   Dim cmds As Commands
   Dim cmdobj As Command
   Dim customin, customout As Object
   Dim cmdbarobj As CommandBar
   Dim colAddins As AddIns

   ' Set references.
   colAddins = DTE.AddIns()
   cmds = DTE.Commands
   cmdobj = cmds.Item("File.NewFile")

   ' Create a toolbar and add the File.NewFile command to it.
   cmdbarobj = cmds.AddCommandBar("MyCmdBar", vsCommandBarType.vsCommandBarTypeToolbar)
   MsgBox("Commandbar name: " & cmdbarobj.Name)
   cmdobj.AddControl(cmdbarobj)
   cmds.AddNamedCommand(colAddins.Item(1), "MyCommand", "Button Text", "Some tooltip", True)
End Sub

권한

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

Command 인터페이스

Command 멤버

EnvDTE 네임스페이스