CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2006
    Posts
    357

    TableLayoutPanel not adding controls

    Hey there,

    Should just be a simple thing i hope...

    I have a table layout panel that i am using for organising images, like a picture grid. Im currently creating the table panel, setting the columncount to 6 then adding some dummy picture boxes.

    The picture boxes have a black background and have a fake Bitmap object contained as well as a fixedsingle border, just to make them show up. However when i do MyPanel.Controls.Add(DummyPictureBox); it shows up in the list of controls with the panel, it just doesnt seem to display them... ive tried refreshing the panel and tried re-sizing it as well as anything else i can think of, and its just driving me mad... any ideas?

  2. #2
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: TableLayoutPanel not adding controls

    can you post your code?

  3. #3
    Join Date
    Nov 2006
    Posts
    357

    Re: TableLayoutPanel not adding controls

    Its spread out a bit but here it is basically

    Code:
    PictureBox Images = new PictureBox();
                   
     // Picture Stylings
    Images.Image = m_Images; // Image loaded previously
    Images.BackColor = Color.Black; // For showing it up even if image isnt correct
    Images.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    
    // Picture Events
    Images.AllowDrop = true;
    Images.MouseMove += OnPictureMouseMove;
    Images.DragDrop += OnPictureDragDrop;
    Images.DragEnter += OnPictureDragEnter;
    Images.Parent = panImageArea;
    
    panImageArea.Controls.Add(Images);
    panImageArea.Refresh();
    Thats pretty much it, an image is loaded via form then passed into a function which loads it all as shown in here. Ive tried manually setting the width/height but it just doesnt display the control. I have also tried manually setting the column/row, still no luck...

  4. #4
    Join Date
    Nov 2006
    Posts
    357

    Re: TableLayoutPanel not adding controls

    just a quick bump incase anyone has any ideas? im gonna have a tinker later see if i can find out what the problem is...

  5. #5
    Join Date
    Nov 2006
    Posts
    357

    Re: TableLayoutPanel not adding controls

    I honestly dont know what the problem was, but its fixed now... i think it *may* have been because i was making controls on the fly, whereas now ive got an array of them and im making them within that then adding them... not that it *should* make any difference...

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

Featured