Hello all,
I'm a long-time developer but semi-new to Visual Studio .NET and VB.NET. I've been working on an application for months, written in Visual Basic .NET. It's a rewrite of a popular IDE of mine that's originally written in assembly.
What I'm trying to do in VB.NET is have multiple TabPage classes that inherit from TabPage, ofcourse, but each having it's own methods for common functions like Cut, Copy, Paste, etc. so that when I call tab.Cut(), the TabPage class for the currently-selected tab is the one used. In each custom TabPage class, I'll have a New instance of the main control that goes in that tab.
I think there would be a problem when I loop through the TabPages since the Foreach routine can only use one object type, as far as I know (TabPage).
Currently I have only one custom TabPage class called Page that obviously inherits from TabPage, has additional properties and also methods that allow editing functions for whatever control is selected to be displayed for the tab. For example, when I call the New constructor, I supply the editor type as a parameter: dim tab as New Page(HEX_EDITOR). I have edit controls such as text, syntax editor, hex editor, bitmap editor, HTML editor, HTML browser. This means I get a new instance of all of those controls each time a new Page is added to the TabControl. I'm currently disposing of the unneeded editors depending on which editor is the one needed. The scheme is not preferred but it works great for now as I work on other areas of the IDE.
I'd like to use a HexPage, TextPage, SyntaxPage, etc. with the TabControl and be able to determine the class of that page later when enumerating through the pages, or when a tab is clicked, etc.
Actually, I'd like to have one base Page class that has my additional properties and some common methods, and all other page classes (hex editor, text editor, etc.) would inherit from that base class but only contain custom methods like Cut, Copy, Paste, Delete, SelectAll, etc. All other methods should drop down to the base class, I hope.
I experimented with all of this and ended up having to have those methods in the base class but with no code inside, and each custom Page used Overloads for the same method name and with code that used the editor control in that custom page class.
I hope I'm explaining the situation well enough, but I'm basically trying to simplify the chore of adding multiple editor types to the IDE, without having to have a single TabPage class that creates a new instance of all of the editor controls when the TabPage object is created, then I'm forced to either leave them be or dispose of the unused controls and just Show() the needed one. As of now my Cut, Copy, Paste routines check the DocType() property to determine which control is in use, then performs the needed edit operations on that control using a Select DocType, Case scheme.
It works like a charm, but it's not ideal, and I really need to have a separate class for each editor/TabPage.
Is this possible and is the TabControl.TabPages() collection compatible?
I'm a long-time developer but semi-new to Visual Studio .NET and VB.NET. I've been working on an application for months, written in Visual Basic .NET. It's a rewrite of a popular IDE of mine that's originally written in assembly.
What I'm trying to do in VB.NET is have multiple TabPage classes that inherit from TabPage, ofcourse, but each having it's own methods for common functions like Cut, Copy, Paste, etc. so that when I call tab.Cut(), the TabPage class for the currently-selected tab is the one used. In each custom TabPage class, I'll have a New instance of the main control that goes in that tab.
I think there would be a problem when I loop through the TabPages since the Foreach routine can only use one object type, as far as I know (TabPage).
Currently I have only one custom TabPage class called Page that obviously inherits from TabPage, has additional properties and also methods that allow editing functions for whatever control is selected to be displayed for the tab. For example, when I call the New constructor, I supply the editor type as a parameter: dim tab as New Page(HEX_EDITOR). I have edit controls such as text, syntax editor, hex editor, bitmap editor, HTML editor, HTML browser. This means I get a new instance of all of those controls each time a new Page is added to the TabControl. I'm currently disposing of the unneeded editors depending on which editor is the one needed. The scheme is not preferred but it works great for now as I work on other areas of the IDE.
I'd like to use a HexPage, TextPage, SyntaxPage, etc. with the TabControl and be able to determine the class of that page later when enumerating through the pages, or when a tab is clicked, etc.
Actually, I'd like to have one base Page class that has my additional properties and some common methods, and all other page classes (hex editor, text editor, etc.) would inherit from that base class but only contain custom methods like Cut, Copy, Paste, Delete, SelectAll, etc. All other methods should drop down to the base class, I hope.
I experimented with all of this and ended up having to have those methods in the base class but with no code inside, and each custom Page used Overloads for the same method name and with code that used the editor control in that custom page class.
I hope I'm explaining the situation well enough, but I'm basically trying to simplify the chore of adding multiple editor types to the IDE, without having to have a single TabPage class that creates a new instance of all of the editor controls when the TabPage object is created, then I'm forced to either leave them be or dispose of the unused controls and just Show() the needed one. As of now my Cut, Copy, Paste routines check the DocType() property to determine which control is in use, then performs the needed edit operations on that control using a Select DocType, Case scheme.
It works like a charm, but it's not ideal, and I really need to have a separate class for each editor/TabPage.
Is this possible and is the TabControl.TabPages() collection compatible?