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.
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
@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