아래의 매크로를 이용해서 컨트롤들의 아이디를 확인하였습니다.

참조 : http://blog.naver.com/PostView.nhn?blogId=heesung2003&logNo=60196368045

 

Sub 컨트롤아이디()
For Each cb In CommandBars
    For Each ctl In cb.Controls
        Cells(Rows.Count, "A").End(3)(2).Resize(, 5) = Array(cb.Name, cb.NameLocal, cb.Visible, ctl.Caption, ctl.ID)
    Next
Next
End Sub 

 

 

컨트롤 아이디를 확인 후  아래와 같이 해당 컨트롤에 접근하여 이벤트를 등록하거나 해당 컨트롤을 숨길 수 있습니다.

 

 

Application app = Globals.ThisAddIn.Application;

 

CommandBarButton delRowBtn = app.CommandBars.FindControl(Id: 293) as CommandBarButton;

CommandBarButton insertRowBtn = app.CommandBars.FindControl(Id: 296) as CommandBarButton;

           

delRowBtn.Visible = true;

delRowBtn.Click += rowDelBtn_Click;

insertRowBtn.Click += insertRowBtn_Click;

 

 

엑셀2013 컨트롤 아이디.xlsx

 

리본 탭의 위치는 특정 컨트롤의 앞이나 뒤에 위치시킬 수 있습니다.

 

예를 들어 홈 탭에 앞에 넣거나 뒤에 넣을 수 있습니다.

 

탭에 대한 아이디는 아래의 경로의 문서를 받아서 확인할 수 있습니다.

 

Office 2013 Help Files: Office Fluent User Interface Control Identifiers
http://www.microsoft.com/en-in/download/details.aspx?id=36798


Office 2010 Help Files: Office Fluent User Interface Control Identifiers
http://www.microsoft.com/en-in/download/details.aspx?id=6627

 

 

 

 

홈탭에 바로 앞에 탭을 추가해보겠습니다.

 

디자이너 Position 속성에서 PositionType은 BeforeOfficeID, OfficeID는 엑셀에서 확인한 TabHome으로 설정합니다.

 

 

 

탭의 위치가 변경된것을 확인 하실 수 있습니다.

 

 

 

숫자를 문자열로 변환할 때 ToString 메서드를 이용합니다.

 

숫자를 문자열로 자주 변경할시에 아래와 같이 LookupTable을 이용하여 구현하시면

 

빠른 속도를 얻으실 수 있습니다.

 

 

 

 

 

 

 

테스트 코드입니다.

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Diagnostics;

 

namespace ToStringOptimization

{

    class Program

    {

        static void Main(string[] args)

        {

            //클래스 메모리 미리 올려두기

            ToStringExtensions.ToStringLookup(1);

 

            Stopwatch st = Stopwatch.StartNew();

            for (int i = 0; i < 256; i++)

            {

                string s = i.ToString();

            }

            st.Stop();

            Console.WriteLine("ToString : {0}", st.Elapsed.ToString());

 

            st = Stopwatch.StartNew();

            for (int i = 0; i < 256; i++)

            {

                string s = i.ToStringLookup();

            }

            st.Stop();

            Console.WriteLine("ToStringLookup : {0}", st.Elapsed.ToString());

 

            Console.ReadKey();

        }

    }

} 

 

테스트 결과 :

 

 

 

 

테스트 프로젝트 : ToStringOptimization.zip

 

+ Recent posts