开发者

how to do multiple pages in VB.NET form

I've inherited some VB.Net code that I think needs some restructuring. The project has three forms, each of which is its own Windows Form file that inherits from System.Windows.Forms.Form.

The problem is that all these forms share a common navigation menu bar that does not change as the user switches between forms, and so the original programmer has duplicated the menu code in each of the three files to generate the menu on each one! I figure this can't be right.

To restructure it, I thought I would create a base form that implemented the menu, and then let the other forms inherit from that, but I ran into the problem that Windows forms already inherit from the class mentioned above, and can't inherit from another class.

I noticed I can add an item called "inherited form", but is that the way to go here? The problem of creating multiple screens with a common menu bar has to be incredibly common. Is there one true w开发者_如何学Cay to do this? Should I use inherited forms, or should I by have just one base form and make the other screens just plain classes and not forms at all? Or something else I'm not thinking of?


Depending on the specifics; you might want to consider using MDI forms.

Another option I've seen is having the menu/shared toolbars be encapsulated in a UserControl and used where desired.


Make a class that inherits from Form class and add the common menu functionality there. Then make your three forms inherit from this new class instead of Form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜