Results 1 to 10 of 10

Thread: Visual Inheritance of a ToolStrip

  1. #1

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Visual Inheritance of a ToolStrip

    Hi,

    This is a known and previously reported problem and promised to be fixed in the "NEXT" version of Visual Studio over and over again.

    Microsoft Connect : https://connect.microsoft.com/Visual...of-a-toolstrip

    I am trying to create an infrastructure library to be used by all my projects where one of the project in that library contains the base forms for different things like ViewBase, EditBase, SearchBase & DialogBase. They all are inherited from a Base form which contains a toolstrip control with 3 common buttons for OK, Close & About.

    Now depending on the type of base form I would like to add few more buttons and controls on the toolstrip during the design time. For example the SearchBase would have a Search, Clear buttons and so forth and so on.

    It it worth noting that I change the modifier of the toolstrip to Protected. None of the inherited form allows me to add a new button or anything on the toolstrip. So I made the modifier public and the same behaviour. All the properties of the toolstrip control are disabled. Why is this? This is kind of a show stopper as I can't rely on the standard controls provided and have to look for third party controls.

    Steps to reproduce this.
    Create a new blank solution
    Add a new project of type class library
    Delete the default Class1 file
    Add a Windows Form named "FormBase"
    Add a ToolStrip control on the form and set the modifier to "Protected"
    Add a button and a label (Don't have to but this is for visual testing)
    Compile the solution
    Now add an Inherited Windows Form named "FormSearchBase" and inherit it from the "FormBase"

    Can anyone else reproduce this?

    I have posted this to Microsoft Connect as a bug but if it gets more support and approval then there is a higher chance of it being fixed.

    Cheers
    WRACK (http://www.codelake.com)
    Last edited by wrack; Apr 16th, 2010 at 10:56 PM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Visual Inheritance of a ToolStrip

    I had a similar situation, I needed to remove a button from the toolstrip and I ended up doing it via code and not at design time. To add more buttons then you can manually via code, either at your designer or in your form.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Visual Inheritance of a ToolStrip

    Thanks for the reply and yes I know what you mean.

    There is a trouble changing the designer code as the moment you change anything else all the custom changes you introduce are gone and you are back to square one.

    The ****** thing is this was working in VS2003 with some minor problems and then they promised to iron out all visual inheritance bugs in VS2005. Along came VS2005 poof, things are even worse so they promised to fix that in VS2008 and well now you know where we are.

    I think we all as a developer has to push this to Microsoft to fix this ASAP by adding more and more confirmations to the connect bug report I filed.

  4. #4

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Visual Inheritance of a ToolStrip

    Can anyone else confirm this please?

  5. #5
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Visual Inheritance of a ToolStrip

    Still doesn't work in VS2010.

    As a 'workaround' you could add a new ToolStrip to the inherited form and add your buttons to that. Then you can either:
    1. Write some code (in the normal code, not the designer code) that transfers the items from the new toolstrip to the inherited toolstrip, and then remove the new toolstrip.
    2. Open the designer file, copy/paste the code that handles adding the items to the new toolstrip, and edit it so that it adds the items to the inherited toolstrip instead.

    Both not very pretty but it should work without having to completely write the 'add items' code from scratch.

  6. #6

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Visual Inheritance of a ToolStrip

    Yeah that is a work around the but the whole point of using Visual Studio is to increase our productivity and create a robust solution. Mucking around with the designer code is not an option and other option is not quite straight forward but doable.

    What we need is all developers racking up to the issue I created at Microsoft Connect and start pushing the number of approvals high enough so the VS team can get off their ass and fix this things once and for all.

    Come on guys, go to the issue and vote for it to be fixed and confirm that you can reproduce this bug.

  7. #7
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Visual Inheritance of a ToolStrip

    I'd vote for this cause.

    Though with MS going WPF these days I don't know if they'd fix an issue like this in WinForms unless it relates to the the same inheritance in WPF too.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  8. #8

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Visual Inheritance of a ToolStrip

    Should be fairly easy to test this for WPF too. I am away from my development machine. Could you please check it and post back?

  9. #9
    New Member
    Join Date
    Apr 2010
    Posts
    1

    Re: Visual Inheritance of a ToolStrip

    This won't work because you're trying to modify the ToolStrip which is actually part of FormBase from inside another class (FormBaseInherited).

    To change FormBase from the editor you can only do that from within the FormBase class - if this were not the case then all other forms inherited from FormBase would also have the changes.

    The only way of doing what you want to do is by manually adding new buttons after the InitializeComponent() in code that is inside your derived form.

    This also just goes to show they give nice generic responses on their help website. To fix this requires a huge addition to .NET

  10. #10

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Visual Inheritance of a ToolStrip

    No offence but that exactly is the whole point of visual inheritance. Like I mentioned this was working in VS2003 (badly) but it did. Then they promised to fix and the keep pushing us in limbo.

    3rd party controls can do this very well.

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