70002871 vdFrameControl support append menu to existing

Article 70002871
Type Wish
Product Engine
Date Added 4/4/2026 12:00:00 AM
Fixed 12.0.02 (4/4/2026 12:00:00 AM)
Submitted by

Summary

vdFrameControl support append menu to existing

Solution

In version 12.0.2
a new optional parameter unloadMenu was added in LoadMenu method

void LoadMenu(string path, string filename,bool unloadMenu = true)
void LoadMenu(System.IO.StreamReader file, string ImagesPath, bool unloadMenu = true)

unloadMenu : Indicates whether to unload the current menu before loading the new one.Optional default value is true.

Example

Suppose you have a 'mymenu.txt' placed in your application folder with the following contents

MainMenu = Custom Objects
SubButton = MyCommand1 , command1 ,
//add more SubButton here

Also you need to append the commands for your menu
Suppose you have a 'mycommands.txt' placed in your application folder with the following contents

command1,,VDCAD TEST.dll,VDCAD_TEST.Commands,TestCommandMethod
//add more commands here

write a windows form application as follow

using vdControls;
using VectorDraw.Professional.vdObjects;
namespace VDCAD_TEST
{
    public partial class Form1 : Form
    {
        vdFramedControl vdraw = new vdFramedControl();
        public Form1()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            this.Controls.Add(vdraw);
            vdraw.Dock = DockStyle.Fill;
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //merge your custom commands
            vdraw.CommandLine.MergeCommands("", "mycommands.txt");

            //add the new menu item at the left side of the exisiting default menu
            vdraw.LoadMenu("", "mymenu.txt", false);
            vdraw.ShowMenu(true);

            ////if you want to add it at the right side then right the following instead
            //vdraw.UnLoadMenu();
            //vdraw.LoadMenu("", "mymenu.txt", false);
            //vdraw.LoadMenu("", "Menu.txt", false);//this will load the default vdraw menu
            //vdraw.ShowMenu(true);
        }
    }

    public static class Commands
    {
        public static void TestCommandMethod(vdDocument doc)
        {
            doc.ZoomExtents();
            doc.Redraw(false);
        }
    }
}


Send comments on this topic.