Results 1 to 4 of 4

Thread: Loading of different panels

  1. #1
    flashkid10 is offline C# Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2016
    Posts
    16
    Rep Power
    7

    Loading of different panels

    I am making a list manager andIi want to add in a details display on the side. the are many different datatypes being displayed on the main table and for each class of data, I want a different panel to show it's unique specific data. I know of the layering panel method, but I am always tweaking the display; so to move all the panels out and edit hen move them back in is rather annoying. is there a way to save a panel and load it in, kinda like different forms in where you tweak them in their own tab and load them in when necessary?

  2. #2
    jmcilhinney is online now C# Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2011
    Posts
    1,468
    Rep Power
    118
    Firstly, there is never a need to move any Panels just to edit them. You can edit them all in place in the designer. Assuming that you have added multiple Panel controls to the form and set all their Size and Location properties to the same values, you can obviously only see one Panel at a time. Which one you can see depends on the z-order. There are a number of ways to change the z-order.

    1. Right-click on the Panel you can see and select 'Send to Back'. This will push that Panel to the bottom of the stack and reveal the next one in the z-order. You can do that multiple times until the Panel you want is displayed.
    2. Use the drop-down at the top of the Properties window to select the Panel you want. This will display a selection border for the Panel, even if the Panel itself is hidden behind another. Right-click that border and select 'Bring to Front'.
    3. Open the Document Outline window from the View menu and then alter the z-order by either drag and drop or using the toolbar.

    Option 3 is the best in my opinion and you may well find other uses for the Document Outline window.

    That said, you might also choose to create user controls instead of using Panels. You can add a new user control to your project and design it in the same way you would a form but then use it in the same way you would any other control.

  3. #3
    flashkid10 is offline C# Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2016
    Posts
    16
    Rep Power
    7
    How would access the items within(mainly textboxs, combobox, and the int counter)?

  4. #4
    jmcilhinney is online now C# Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2011
    Posts
    1,468
    Rep Power
    118
    I assume that, without actually saying so, you mean accessing child controls of a user control. In that case, you have two options:

    1. You can set the access level of the controls you add to 'public' and they can then be accessed from outside the user control. That's the simple option but it's dodgy.
    2. Add pass-through members to your user control for each member of a child control you need to access. For instance, if you need to access the Text property of a nameTextBox control then do this:

    public string NameText
    {
    get
    {
    return nameTextBox.Text;
    }
    set
    {
    nameTextBox.Text = value;
    }
    }

Tags for this Thread

Bookmarks

Posting Permissions

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