PictureBox and Transparency


Hi all;

I'm displaying png icons on BusinessPartner Form according to a userfield value.

The code works fine, but i did not found any way to manage transparency for my images.

All info i've found are for menu icons,for wich transparency is set by using color rvb(192,220,192)

Is there anyway to do that with PictureBox?

Thanks for help;

Paolo Manfrin

Unfortunately transparency is not supported in B1,

Please could you post the picture so maybe we could suggest a workaround?




Hi Paolo;

Here is a sample icon i am displaying.

(we use a set of 5 Icon to have a quick view of custommer status)

Changing the background of the image by the background color of sap and having all the clients with the same color settings do the trick for now.

Do you think of generating a new set of picture with sap background color at connection ?

[attachment=302:Bouée client à suivre.png]



Paolo Manfrin

Hi Emmanuel,

the trick you are already using was the one I wanted to suggest :-)




It has been a bit painfull, but it works... Didn't found any way to get default color code for forms, but I've managed to get the right color with testing oudg and oudr color fields.

We have nice icons in sap now (nice sample made recently : Page icon that appears on sales document if any header or footer enterred, and wich can be used to open Doc Header/Footer form... Nice and easy :D )

Here is the result, and code sample bellow.



Dim bckcolor As System.Drawing.Color

Dim DefColorCode As Integer

DefColorCode = layouthelper.LD.QueryData("SELECT coalesce(T0.Color,T2.Color ) FROM OUDG T0 full outer JOIN OUSR T1 ON T0.Code = T1.DfltsGroup , OADM T2 where T1.Internal_k='" & ocmp.UserSignature & "'")

Select Defcolorcode

Case 0

bckcolor = System.Drawing.Color.FromArgb(255, 234, 241, 246)

Case 1

bckcolor = System.Drawing.Color.FromArgb(255, 234, 241, 246)

Case 2

bckcolor = System.Drawing.Color.FromArgb(255, 243, 243, 243)

Case 3

bckcolor = System.Drawing.Color.FromArgb(255, 241, 238, 250)

Case 4

bckcolor = System.Drawing.Color.FromArgb(255, 240, 255, 249)

Case 5

bckcolor = System.Drawing.Color.FromArgb(255, 240, 249, 228)

Case 6

bckcolor = System.Drawing.Color.FromArgb(255, 255, 254, 238)

Case 7

bckcolor = System.Drawing.Color.FromArgb(255, 255, 248, 219)

Case 8

bckcolor = System.Drawing.Color.FromArgb(255, 248, 232, 241)

Case 9

bckcolor = System.Drawing.Color.FromArgb(255, 241, 234, 225)

End Select

ImageCible = New System.Drawing.Bitmap(75, 75)

Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(ImageCible)

g.FillRectangle(New System.Drawing.SolidBrush(bckcolor), 0, 0, ImageCible.Width, ImageCible.Height)

' Draw ImageCible picture

If Not ImageBase Is Nothing Then

g.DrawImage(ImageBase, 0, 0, ImageCible.Width, ImageCible.Height)

End If

Dim savePath As String = System.IO.Path.GetTempPath() + "\sap_background_" & satisf_level.ToString & ".png"


oPictureBox = picturebox.GetFromUID(oform, "S_ImgCli")

oPictureBox.Picture = savePath




Paolo Manfrin

Thanks for sharing your solution Emmanuel!





Please sign in to leave a comment.

Didn't find what you were looking for?

New post