1
votes

I want to make the backgroundImage of my tabPages spread out to the available size.

According to other topics here on StackOverflow, I set the BackgroundImageLayout in my Forms properties to Stretch, but my background image is still being displayed as a tile.

Is there another flag I have to set? I feel like the seemingly global property does not quite affect tabPages.

PS: If it is of any significant matter, the picture is being added at runtime.

EDIT: This is how my Picture is being added to the tabpage as background:

TabPage tab = new TabPage();

tab.BackgroundImage = Image.FromFile(*path*);

tabControl.TabPages.Add(tab);

while tabControl is passed as a parameter inside the class, coming straight from my Form via this.tabControl

The fetching of the image works.

Also, the stretch attribute is currently set inside the forms properties.

1
It is a bit difficult to know what you are doing wrong without seeing a code or understanding what you did exactly. Note that you can affect the properties of the given tabpage either from the design view or from the code (at runtime). By changing the BackgroundImageLayout property, the image should be modified accordingly. Why is not this the case with you? No idea. Please, help us to understand such a mistery. BTW, with the tag forms you meant Winforms? Because this control also exists in WPF.varocarbas
?! Can you please provide ALL the relevant code and/or instructions. That is: TabControl + TabPage + Stretch.varocarbas

1 Answers

1
votes

a BackgroundImage object has more properties, and one of those is the placement of the image constrains... the available layouts are:

  • None
  • Tile
  • Center
  • Stretch
  • Zoom

play with those and choose the one that fit your needs:

tab.BackgroundImageLayout = ImageLayout.Stretch;

as it probably be a fixed layout, you can also use the UI for given the correct layout, but it's up to you...

enter image description here