.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing the Toolbar Button Name Programmatically

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
archanavalli
551 Views, 2 Replies

Changing the Toolbar Button Name Programmatically

The requirement is to programmatically change the name of a toolbar button.

 

 I am currently getting the toolbar button and changing the value using 

 

 

 

 

 

CustomizationSection cs;

 

string mainCuiFile = (string)Application.GetSystemVariable("MENUNAME");

 

mainCuiFile +=".cuix";

 

cs = new CustomizationSection(mainCuiFile, false);

 

ToolbarCollection toolColl = cs.MenuGroup.Toolbars;

 

foreach (Toolbar toolBar in toolColl)

 

{

 

   ToolbarItemCollection itemColl = toolBar.ToolbarItems;

 

   foreach (ToolbarItemBase item in itemColl)

 

   {

 

      try

 

      {

 

 

         if (item is ToolbarButton

              && ((ToolbarButton)(item)).MenuMacroReference !=null)

         {

              Macro macro = ((ToolbarButton)(item)).MenuMacroReference.macro;

              if (macro.Name.ToUpper() == "SYNCHRONISE ...")

              macro.Name ="test";

         }

 

 

      }

      catch (System.Exception ex){}

}

}

 

 

ed.Document.SendStringToExecute(

"cuiunload " + cs.MenuGroup.Name + " ", false, false, false

);

 

Application.SetSystemVariable("FILEDIA"

, 0);

ed.Document.SendStringToExecute(

"cuiload c:\test.cuix ", false, false, false

);

But the Name of the button does not change.

Please let me know what I am missing here.

 

 

2 REPLIES 2
Message 2 of 3

 


@archanavalli wrote:
Please let me know what I am missing here.


IMHO you are missing cs.Save()

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 3
archanavalli
in reply to: archanavalli

Thank You Alexander 🙂 That fixed my problem...

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost