0
votes

I have painted with a gradient my winforms. I´m using a panel in one of them with AutoScroll = true. That way, I can display all the info without taking to much space.

Now, I want that panel to be transparent. I use transparent as background color and works fine. The problem is when I scroll. The transparency messes up. Is there any way to solve this problem?

I also tried to paint the panel with the same gradient that my form has after knowing the final height. But I have the same problem.

Here are some images: (don´t look at the textboxes or those transparent small panels. That will be white).

Before scrolling (RIGHT) enter image description here

After scrolling (Backcolor issue) enter image description here

Another one after scrolling:

enter image description here

2
You're pushing the poor winforms too far. Its not meant for such things. Better go with WPF. - Federico Berasategui
Well, thats not an option. I´m mixing some WPF windows with some Winforms, but I don´t know a lot of WPF and besides, this form I´m showing is already finished in Winforms. If this background transparency cannot be done I will just select a solid background.. - Andres
Of course it can be done.. anything can be done. It just can't be done easily. - Sam Axe
Add an event handler for the panel's Scroll event and call the panel's Invalidate() method. That will fix the background but it isn't going to look very good while you scroll. You'll see a pogo effect. An unavoidable side-effect of the "Show window content while dragging" Windows option, one you cannot reasonably turn off. - Hans Passant
Thank you Hans Passant! Write that in an answer if so as to select it.. - Andres

2 Answers

1
votes

I had the same issue. Calling panel.Refresh() looked better & smoother than Invalidate().

0
votes

I will be quoting the answer:

Add an event handler for the panel's Scroll event and call the panel's Invalidate() method. That will fix the background but it isn't going to look very good while you scroll. You'll see a pogo effect. An unavoidable side-effect of the "Show window content while dragging" Windows option, one you cannot reasonably turn off. – Hans Passant