Results 1 to 4 of 4

Thread: [2.0] problems with setting Parent & displaying icons

  1. #1

    Thread Starter
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    [2.0] problems with setting Parent & displaying icons

    two questions:

    firstly, I'm adding a form to a panel to a panel using the following code:
    VB Code:
    1. Form frm = new Form2();
    2. frm.TopLevel = false;
    3. frm.Parent = panel1;
    4. frm.Show();
    but Form2 is never activated and the non-client area is never drawn as active either. is there an easy solution?

    secondly, I've added images to my toolbar buttons, which display in the designer, but not when i run the code...

    the attached image shows both problems - and I'm very much noobing it with C# at the moment, so be easy on me!

    Attached Images Attached Images  

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] problems with setting Parent & displaying icons

    You should be using an MDI interface, not embedding forms directly into the parent. I assume that you have a ToolStripContainer in the parent form and that's why you're doing that, but it's not necessary. You can add individual ToolStripPanels to the edges of the form that you want to be able to drag ToolStrips to, which doesn't cover the entire client area the way a ToolStripContainer does. The ToolStripPanel is not in the Toolbox by default so you need to add it manually.

    Note that you need careful what order you add your controls when doing this. Once you have a ToolStripPanel in the designer with no strips in in it seems to be impossible to drag any existing controls into it. What you can do in that case is select the ToolStripPanel in the Properties window, add a new ToolStrip to it from the Toolbox to expand it, drag your existing ToolStrip into it and then delete the dummy.

    Below is an image of a genuine MDI form I created using these steps. Here's the code I used to change the background colour of the client area in the Load event handler:
    VB Code:
    1. For Each cntrl As Control In Me.Controls
    2.     If TypeOf cntrl Is MdiClient Then
    3.         cntrl.BackColor = Color.Magenta
    4.     End If
    5. Next cntrl
    Obviously you'll want to choose a less offensive colour.
    Attached Images Attached Images  
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] problems with setting Parent & displaying icons

    Oops. Just realised I'm in C# land. That code should be:
    Code:
    foreach (Control cntrl in this.Controls)
    {
        if (cntrl is MdiClient)
        {
            cntrl.BackColor = Color.Magenta;
        }
    }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [2.0] problems with setting Parent & displaying icons

    thanks for the reply jmcilhinney, I probably should have explained a bit more about what I'm doing. The user needs to be able interact with the area behind the child forms - below is an example i posted in this thread last year when I was trying to do this in VB6:



    well i managed to do it in VB6 - using a MDIChild that was always kept the same size as the MDIForm client area and using SetParent to place the child forms within that + plus a large dose of subclassing (i implemented other things that restricted the size / position of the child forms - which I'm not so bothered about this time) - anyway I was hoping it might be a bit simpler in .Net, or am I going to have to start flinging the APIs around?

    and do you know why those icons are displaying incorrectly in the first post?

    cheers

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