Click to See Complete Forum and Search --> : TableLayoutPanel not adding controls


Grofit
March 30th, 2009, 02:17 AM
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?

eclipsed4utoo
March 30th, 2009, 05:43 AM
can you post your code?

Grofit
March 30th, 2009, 05:57 AM
Its spread out a bit but here it is basically


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...

Grofit
March 31st, 2009, 02:13 AM
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...

Grofit
April 2nd, 2009, 02:53 AM
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...