.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Dynamic controls (buttons) over PictureBox not displaying correctly.
 

Dynamic controls (buttons) over PictureBox not displaying correctly.

This afternoon I was making a very long code to display a series of activities in a graphic way.

Each activity is represented by a nice button, and between activities there are pointing arrows and start and end markers (these last ones aren't implemented yet). Something similar to a workflow.

It's a very simplistic chain of runtime generated buttons, so it has no point posting the code. The code just align the buttons, break them in lines, calculates coordinates, etc.

The buttons are in front of a picturebox that should display the static objects, that is the arrows and the markers (and setting the background color to fuzzy button boundaries). Buttons has two images: one for normal state (not pressed, with shadow), and anothe for pressed state. That's working perfectly.

The upper half of the main form is filled with this 'graphic' thing, which resizes automatically depending on its size. The bottom half has some comboboxes and datagriedviews, to display information about the activities.


My problem is that, buttons are generated, but the picturebox that is supossed to use as background is always on top of the buttons (setting its visibility to false show me the cute buttons).

I tryed everything I know, googled a lot, and I have no idea how to make this work. I'd like to use picturebox but if it's impossible, I'll set the background image on form (primarirly because picturebox image automatically repaints). I'd like to try picturebox way.

SendToBack and BringToFront do nothing with z-order. Picturebox always remains on top.

- Controls are placed on a panel, so the picturebox.

This is being developed in .NET 2.0 and there is no way to use WPF.


I haven't any fresh brain cell to think about it... all of them fried the whole afternoon with the giant code (and it isn't ended yet, hehehe). Thanks in advance to everyone that waste his time reading my post.


Saludos.


Ing Rosell
fabrosell
I've solved the problem, thanks to your suggestions (simplistic but helpful).

When adding buttons, I've set BringToFront BEFORE adding control. If it's set after, the control displays correctly.


That's all.

Thanks for your suggestions, them gave me clues to find the solutions.


Saludos.

Ing Rosell
  • Marked As Answer byfabrosell Wednesday, October 01, 2008 1:52 PM
  •  
fabrosell
Can't duplicate your result.
JohnWein
This is clearly a Z-order problem. The order in which you called Controls.Add() matters, SendToBack/BringToFront certainly should rearrange the order. Since you are using panels, be sure not to forget about the Z-order of the panels themselves.
Hans Passant.
nobugz
I've solved the problem, thanks to your suggestions (simplistic but helpful).

When adding buttons, I've set BringToFront BEFORE adding control. If it's set after, the control displays correctly.


That's all.

Thanks for your suggestions, them gave me clues to find the solutions.


Saludos.

Ing Rosell
  • Marked As Answer byfabrosell Wednesday, October 01, 2008 1:52 PM
  •  
fabrosell

You can use google to search for other answers

Custom Search

More Threads

• pager message send issue
• How to add a custom section to app.config
• folder gets buggy after issued: System.IO.Directory.Delete(dir) call.... :(
• How to write a Char formate in 8 bytes
• Custom Configuration Section
• Registry Optimization Using vb.net
• Detect when certain keys are pressed behind security dialog box
• Facing a problem with file delete - UnauthorizedAccessException
• can we write the pdf content into text file using .net
• Must I define <source> in app.config for every single TraceSource?