1

I have a window with a Tabbed Layout Pane containing 2 panels,The Dockmode of the tabbed layout pane is set to Fill.I need to put a Panel/Picturebox that indicates background processing at the center of the form and and on top of all the existing controls (or) on top of the first picturebox on the left pane

enter image description here

I have tried

  • Putting the PictureBox Panel on right panel,setting bring to front and moving the PictureBox panel using keyboard,but the PictureBox panel stays below.
  • Putting the picturbox containing the loading animation on top of the panel 1 picturebox is also an option,but i cannot place the loading picturbox on top of the existing picturebox.

Please help

techno
  • 6,100
  • 16
  • 86
  • 192
  • You can put it as direct child of the `Form` and then [show it](https://stackoverflow.com/a/39142535/3110834). If you have issue on setting parent of a control, use [*Document Outline*](https://stackoverflow.com/a/32331827/3110834) window and drag the control in the window to set its new parent and z-index. – Reza Aghaei Apr 03 '18 at 05:55
  • @RezaAghaei The issue is that i cannot put the picturebox where i want it to be.. When i draw the picturebox on panel 1,it immeditately disappears. – techno Apr 03 '18 at 06:00
  • As you can see Panel 1 already contains a pictuebox,the background task is performed when the user presses a button.Is there any other way to show the loading animation .. does putting the code in onpaint work? – techno Apr 03 '18 at 06:01
  • I'd simply use [the option](https://stackoverflow.com/a/39142535/3110834) which I linked in the first comment. – Reza Aghaei Apr 03 '18 at 06:04
  • @RezaAghaei But what signals the loading animation ? Can it be triggered by a button click ? – techno Apr 03 '18 at 06:14
  • Anything, for example it can be triggered by `LoadData` method like the example. – Reza Aghaei Apr 03 '18 at 06:21
  • @RezaAghaei I have tried using your TransparentPictureBox Control,No loading animation is displayed... – techno Apr 03 '18 at 17:25
  • First you should be able to show a loading gif using a common `PictureBox` like what I described in [this post](https://stackoverflow.com/a/39142535/3110834). The next step is trying to use `TransparentPictureBox` which is described in the [other post](https://stackoverflow.com/a/37473192/3110834). Those answers are approved working answers and they show some screenshot of working result. – Reza Aghaei Apr 03 '18 at 17:33
  • @RezaAghaei Yes,i can simply display the loading GIF with a picturebox,but i cannot place the picturebox on top of another picturebox as i have set the `Dock` to fill.Secondly i have tried using your control,but when setting the image,no loading animation is displayed. – techno Apr 03 '18 at 17:36
  • What you are describing are 2 different problems. As mentioned in previous comments, to solve positioning problem use *Document Outline* window. `TransparentPictureBox` is totally irrelevant to positioning problem and it's just a feature. – Reza Aghaei Apr 03 '18 at 17:41
  • To test a solution, use a clean environment. Don't mix different things together. That's the whole point of writing [MCVE]. – Reza Aghaei Apr 03 '18 at 17:42
  • I'm not sure if you read comments carefully :) – Reza Aghaei Apr 03 '18 at 17:42
  • @RezaAghaei How can Document Outline window solve positioning problem,if im unable to place the control on the form. – techno Apr 03 '18 at 17:45
  • How can I help someone who even didn't try that! Just for example, create a new `Form`, drop a `Panel` on form and set its `Dock` to `Fill`. Then drop a `PictureBox` on panel. Then using *Document Outline* window, in tree view, drag the `PictureBox` and bring it up the panel node in tree view. This way you are setting the `Form` as parent of the `PictureBox`. Then to move the picture box to a suitable position, use arrow keys and don't use mouse or use Properties window. – Reza Aghaei Apr 03 '18 at 17:50
  • As another simple solution, without using designer, you can simply create `PictureBox` at runtime and add it to `Controls` collection of the `Form` and when needed simply bring it to front. – Reza Aghaei Apr 03 '18 at 17:51
  • @RezaAghaei I can be stupid at times(maybe lazy) :) This worked like a charm. Thanks a lot for your help :) – techno Apr 03 '18 at 17:54
  • Thanks god! ;) You're welcome :) I'll add it as answer. – Reza Aghaei Apr 03 '18 at 17:55
  • okay.... will accept and upvote it. – techno Apr 03 '18 at 17:57

1 Answers1

1

To solve the positioning problem you can use either of the following options:

  1. Run-Time Solution: Create your PictureBox at run-time
  2. Design-Time Solution: Use Document Outline Window to position control

Run-Time Solution

You can simply create PictureBox at run-time and add it to Controls collection of the Form and when needed, simply bring it to from using BringToFront method.

Design-Time Solution

You can use Document Outline window to change parent of the controls and their z-index. You can simply drag and drop tree nodes (controls) to change parent and z-index of the control.

Just for example, create a new Form, drop a Panel on form and set its Dock to Fill. Then drop a PictureBox on panel. Then using Document Outline window, in tree view, drag the PictureBox and bring it up the panel node in tree view. This way you are setting the Form as parent of the PictureBox. To move the picture box to a suitable location on form, use arrow keys or use Properties window. Don't use mouse, if you use mouse to change the location, you will change the parent unintendedly.

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398