The application can support N number of TopLevelMenu elements. It uses a root element to encompass the TopLevelMenu elements. There's really nothing too extreme about the XML structure. The main purpose of this control is to generate an applications menu via a MenuStrip control, at runtime, based on values provided in an XML configuration file that can be located in a file system folder or embedded as a resource directly in to your application. I'm sure there are other interesting things to note as well. For a more detailed explanation, check out Jim Hollenhorst's CodeProject article: " Upgrading from MainMenu and ToolBar to MenuStrip and ToolStrip." Things to NoteĪside from showing how to enhance the MenuStrip control to use an XML file as its data source, this control also shows some pretty basic techniques for using Reflection, loading files from embedded resources, parsing an XML file, and organizing an XML file. There are some noticeable differences in the two. One main thing here is that this control uses the new, relatively speaking. Of course, I'm sure there are many more pros and cons that you can come up with, but these were just a few that I came up with off the top of my head. Supporting the application becomes a bit more difficult as Support no longer has the ability to say for certain where to go in the menu structure as their "File" could be easily renamed to "Option1" (just an example).This could become confusing if someone renames the "File > Exit" MenuItem to "File > Open." Customers, End Users, Developers, etc., have the ability to rename their MenuItem elements at any time.A decent way to get new developers started on the learning curve for the application.can rename MenuItem in the XML configuration file to better suit their needs or to give a MenuItem more "meaning" in their environment. Customers, end-users, developers, etc.Adding and removing ToolStripMenuItem does not require an application rebuild.This is where I originally got the idea for the XML-driven Menu Strip. Having to make a separate build for each of the customers just because we want to rename one of their menu items was not a feasible solution. This typically controls how dynamic an application should be as well as how customizable an application should be. As many developers know, customers tend to want different things out of the application. Each customer puts more focus on different areas of the application than the other customers, which is perfectly understandable. The company that I work for has multiple clients that run our application. NET 3.0 will pretty much make this control out-dated with WPF and XAML, but in the meantime, why shouldn't I be able to supply a path to an XML configuration file to setup my MenuStrip control and have it generated at run time as opposed to hard coding all the ToolStripMenuItem values at design time. The only thing I can come up with to really answer this is … "why not?" I mean. Honestly, I've battled with the concept of an XML driven menu, and while I'm still not fully convinced that it would be 100% useful in all situations … I can see how it would be useful in some applications. This is a generalized re-usable control written in such a way that it can be easily plugged in to any application based on the application's requirements. Things like: Caption, Name, Text, and the corresponding Event it has to trigger when a user clicks a MenuItem. The MenuStrip will be based on XML data which contains all the details about the generated menu. The post How to create Visual Basic Context Menu Strip appeared first on Bubble Blog.In this article, I'll be showing how you can generate a dynamic MenuStrip (.NET 2.0's replacement of the MainMenu control) via an XML Configuration file, using recursion in C#. We have already covered it in our post for Taskbar Notification in Visual Basic. Coding for Context MenuĬontext menus can also be added programmatically. Run the application and see click action yourself. Private Sub menuItem2_Click(ByVal sender As Object, ByVal e As System.EventArgs)Īt Form Load, we have added Handlers for Click events of Menu Items. Me.WindowState = FormWindowState.Maximized Private Sub menuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'Add functionality for ToolStripMenuItem2 (Exit) clickĪddHandler ToolStripMenuItem2.Click, AddressOf menuItem2_Click ' Add functionality for ToolStripMenuItem1 (Maximize) clickĪddHandler ToolStripMenuItem1.Click, AddressOf menuItem1_Click Private Sub Form1_Load(ByVal sender As System.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |