Results 1 to 14 of 14

Thread: Tabbed MDI Text Editor

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Tabbed MDI Text Editor

    I have created a Tabbed Multi-Document-Interface Text Editor using just standard controls and custom modified controls.

    See the screenshot:



    In this post I will try to explain exactly how I managed to do it and I have attached the project source (VS2008 only, sorry). If I manage to find the time for it, I might post the code split up into individual files and explain how to add the code and to which file, so you can get it to work on older versions of Visual Studio as well.


    As far as I know there is no way of creating a real tabbed MDI application with Visual Studio and its standard controls, although there are a large number of third party controls available which handle it really well, but are also really expensive and not really an option for any 'stand-alone' coder or hobbyist.
    That's why I decided to try and 'fake' a tabbed MDI application using standard controls only, and that's also why I provide it for free here...

    Now, instead of actually using MDI Forms, my application uses a custom control inheriting from a TabControl (although it is nearly the same using a standard TabControl) and custom TabPages which host a RichTextBox. This simulates the use of Tabbed MDI forms really well, although it makes it nearly impossible to switch between the tabbed and untabbed MDI look.


    First, the custom TabControl (called cTabControl). This is simply a UserControl which inherits from the TabControl, making it behave exactly like a normal TabControl except for a few tiny things, which I thought were easier to do by creating a custom TabControl. As I've said I think it can be done easily using a normal TabControl.

    The custom TabPage (called cTabPage) is also just a UserControl, this time inheriting from a TabPage. This TabPage differs from the standard TabPage because it already has a RichTextBox (called RTB) on it.


    Most of the standard text-editor features are present:
    - New, Open, Save, Save As features
    - Cut, Copy, Paste, Select All features

    And a few 'new' features which are useful for an MDI application have been added:
    - The 'Open File' feature is able to open multiple files simultaneously
    - Save All feature which saves every document
    - Close All Documents feature which closes every document
    - Close feature which closes the active document

    There is also a StatusBar which hosts a label displaying the filepath of the active document and the current Line and Character positions ("Ln x, Ch y").

    I have also added a handy little feature I got from Visual Studio itself: you can rightclick a tab header and a Contextmenu drops down where you can quickly Save or Close the selected tab.


    One drawback of not using actual MDI Forms was that the 'Window' list of open documents could not be created automatically, so I had to list the windows manually.
    I managed this by using the WindowToolStripMenuItem's "DropDownOpening" event which fires just before the dropdown menu is shown. First I clear the list. Then I add a ToolStripMenuItem for each open document. The document (tab) itself is stored in the Tag of this MenuItem so it can be handled accordingly when it is clicked.


    But, enough talk. If you have VS2008 you can download my attachment which contains the complete project. You should be able to run it without making any changes. If this is not the case please let me know!

    If you take a look at my signature, you can also have a look at the (non-tabbed) Extensive MDI Text Editor I have created. This contains a LOT more functions like document Splitting, synchronized scrolling etc etc... I don't think it will be very hard to translate features from that project to this Tabbed version, but if you want to try and cannot manage it, let me know and I'll try to help!


    Lastly, there is still alot of work that can be done on this project and I might add things to it in time...

    If anyone finds any errors or bugs please let me know and I'll try to fix them! Also, if anyone sees anything I shouldn't be doing please tell me. (I'm just a hobby coder so I'm sure I'm not doing much things the right way ).



    Enjoy!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width