C# - Custom ToolStrip

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LukasMalik
    New Member
    • Jan 2008
    • 22

    #1

    C# - Custom ToolStrip

    Hi,

    I have widely used ToolStrip in my application. I created a UserControl which contains this ToolStrip. I would rather like to use inheritance:

    MyCustomControl : ToolStrip

    Everything seems to work fine, untill I want to set visibility to one of ToolStripItem - there are maybe 20 buttons and not all of my ChildForms which contains this MyCustomControl need all of them. I open in designer mode in Property window "Items", choose right one and than select "Visibility " > false. In designer mode button dissapear. When compile, designer is reloaded, button is back again.

    If I code manually in constructor of ChildForm:

    myCustomControl .Items["someButton "].Visible = false;

    it worsk OK.

    What would you advice me, please?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    When compile, designer is reloaded, button is back again.
    If the button wasn't visible in the designer how would you ever be able to click on it again to change it's properties? It has to remain visible in the designer in order for you to work with it.

    Does it's 'visible' property remain set to 'false' ?
    When you actually run your application after setting it to false, does it disappear on the appropriate child forms?

    Comment

    • LukasMalik
      New Member
      • Jan 2008
      • 22

      #3
      I see property Visible in "Property window" in my Visual Studio.
      I also change it to -> False. Than, it turns to bold and it seems to be OK. When I build, designer reloads Form and property is again "True".

      When I open Form.designer.c s, I dont see generated row for that

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Sounds like your UserControl is not handling that property correctly.

        Since the menu is an item of your new UserControl there would have to be "Visible" properties in the UserControl for each of the items in the ToolStrip. Do you have that?

        Comment

        Working...