8 Replies - 710 Views - Last Post: 16 September 2019 - 06:59 AM Rate Topic: -----

#1 cpssantos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-September 19

How to create transparent Listbox

Posted 16 September 2019 - 04:40 AM

Is there a way to make a listbox transparent and its text still opaque so that a control behind it can be seen?
Is This A Good Question/Topic? 0
  • +

Replies To: How to create transparent Listbox

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,229
  • Joined: 12-December 12

Re: How to create transparent Listbox

Posted 16 September 2019 - 05:33 AM

What type of application are you bulding? WPF? (older) WinForms? Etc..
Was This Post Helpful? 0
  • +
  • -

#3 cpssantos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-September 19

Re: How to create transparent Listbox

Posted 16 September 2019 - 05:43 AM

View Postandrewsw, on 16 September 2019 - 05:33 AM, said:

What type of application are you bulding? WPF? (older) WinForms? Etc..

I'm Using WinForms, I'm trying to make a ListBox with a visible PictureBox behind it like a watermark.
Was This Post Helpful? 0
  • +
  • -

#4 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 381
  • View blog
  • Posts: 1,621
  • Joined: 07-September 13

Re: How to create transparent Listbox

Posted 16 September 2019 - 05:47 AM

If it is WinForms. Then Microsoft did shy away from making scrollable controls be able to have transparent backgrounds... as I recently found out.

This is because as you scroll your transparent items within a scrollable control will need to repaint the background, remember they will be calling Me.Invalidate or Me.Refresh for every pixel it is moved, because of this your transparent items will get repainted a lot. This can have a knock-on effect that while scrolling quickly, like by dragging the scroll bar down, your transparent items background becomes blurred. It all sorts itself out when you finish scrolling but I am guessing this is a big reason why most / if not all scrollable controls don't support transparent backgrounds, at least in WinForms.

I found this out while making my own scrollable control recently with a panel, TableLayout Control and custom user controls. I found workarounds with my issue's, however, mine is no longer true transparent background.
Was This Post Helpful? 0
  • +
  • -

#5 cpssantos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-September 19

Re: How to create transparent Listbox

Posted 16 September 2019 - 06:08 AM

View Postmaceysoftware, on 16 September 2019 - 05:47 AM, said:

If it is WinForms. Then Microsoft did shy away from making scrollable controls be able to have transparent backgrounds... as I recently found out.

This is because as you scroll your transparent items within a scrollable control will need to repaint the background, remember they will be calling Me.Invalidate or Me.Refresh for every pixel it is moved, because of this your transparent items will get repainted a lot. This can have a knock-on effect that while scrolling quickly, like by dragging the scroll bar down, your transparent items background becomes blurred. It all sorts itself out when you finish scrolling but I am guessing this is a big reason why most / if not all scrollable controls don't support transparent backgrounds, at least in WinForms.

I found this out while making my own scrollable control recently with a panel, TableLayout Control and custom user controls. I found workarounds with my issue's, however, mine is no longer true transparent background.

Well that's a bummer, but can my desired result of having a ListBox with a watermark achievable with other means? I tried a custom class from the internet that will create "proper" transparency for a control by drawing every control that's behind it onto it's background but the items from the ListBox still gets behind it. If there is another way to accomplish that result, can you please guide me to it :helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#6 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 381
  • View blog
  • Posts: 1,621
  • Joined: 07-September 13

Re: How to create transparent Listbox

Posted 16 September 2019 - 06:16 AM

It most likely can be done another way, in fact, I believe in my last place, we put watermarks on every item within the Listbox, and custom drew them in a nice way.

I don't have any of the code to hand anymore and would take me a while to replicate it, time which I don't seem to have ATM. but would that be a workaround?
Was This Post Helpful? 1
  • +
  • -

#7 cpssantos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-September 19

Re: How to create transparent Listbox

Posted 16 September 2019 - 06:24 AM

Yes, that would be a nice work around, and there will be no scrolling done in the ListBox so no problems of having blurry background.
Was This Post Helpful? 0
  • +
  • -

#8 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 381
  • View blog
  • Posts: 1,621
  • Joined: 07-September 13

Re: How to create transparent Listbox

Posted 16 September 2019 - 06:46 AM

exactly.

If you give that ago then, if you have any problems come back and post what you have attempted and someone will be happy to help when they have the time, I am sure.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,178
  • Joined: 12-June 08

Re: How to create transparent Listbox

Posted 16 September 2019 - 06:59 AM

Alternatively you can find a third party control system what you want, use WPF, or build your own.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1