Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We have a similar implementation at work. This is a pretty straightforward design and works well.</p> <p>You may want to add a unique identifier to each MenuItem. This can be as simple as:</p> <pre><code>public enum MenuItems { File_New = 100, File_Save = 110, // ... } </code></pre> <p>And you include this number in the database. Then, when you write out the menu items, you can have a dictionary that maps the MenuItems integer to a delegate (for handling the execute event):</p> <pre><code>delegate void MenuItemExecuteHandler(); IDictionary&lt;int, MenuItemExecuteHandler&gt; MenuItemHandlers; </code></pre> <p>And somewhere define the mappings:</p> <pre><code>MenuItemHandlers.Add(MenuItems.File_New, this.OnFileNewClick()); </code></pre> <p>So that when you hookup the menu item event handlers, you can call the right method to perform the right action:</p> <pre><code>int id = 100; // Retrieved from the database. MenuItems menuItem = (MenuItems)Enum.TryParse(typeof(MenuItems), id); string command = "..."; // Retrieved from the database using the MenuItem ID. MenuItemControl control = new MenuItemControl(); control.Text = command; control.OnClick += new EventHandler(delegate (object sender, EventArgs args) { MenuItemHandlers[menuItem].Invoke(); }); </code></pre> <p>(Something to that effect, I probably have the syntax off slightly)</p> <p>Update:</p> <p>The "Tag" property of the tree-view item control gets populated like this, following the example above:</p> <pre><code>TreeItemControl control = new TreeItemControl(); control.Text = "New File"; // Retrieved from database. control.Tag = 100; // Retrieved from database. </code></pre> <p>Then, when looking for what to write out:</p> <pre><code>if (control.CheckState = CheckState.Checked) { row["MenuItemID"] = control.Tag; row["Allowed"] = true; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload