Transparent Pictureboxes
-
I have a class called "Card" (as in a deck of cards), which extends the PictureBox class. Now the picturebox is the size of the image (150X215). When you mouse over the card it "hovers" (its Y location decreases 20 pixels) and is supposed to show part of the card underneath it. However this does not happen. See this picture: http://img199.imageshack.us/i/cardsj.jpg/[^] I've done this in the OnLoad event of the Card class: this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; But it doesn't work (as you can see in the picture). I found this article: http://www.codeproject.com/combobox/TransListBox.asp[^] But how do I do this in C#? BTW the images are transparent png's.
-
I have a class called "Card" (as in a deck of cards), which extends the PictureBox class. Now the picturebox is the size of the image (150X215). When you mouse over the card it "hovers" (its Y location decreases 20 pixels) and is supposed to show part of the card underneath it. However this does not happen. See this picture: http://img199.imageshack.us/i/cardsj.jpg/[^] I've done this in the OnLoad event of the Card class: this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; But it doesn't work (as you can see in the picture). I found this article: http://www.codeproject.com/combobox/TransListBox.asp[^] But how do I do this in C#? BTW the images are transparent png's.
Using pictureboxes for this, is a little insane. Just draw your cards onto your form in your paint event.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Using pictureboxes for this, is a little insane. Just draw your cards onto your form in your paint event.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
I've changed it from PictureBox to Panel and added this:
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);pe.Graphics.DrawImage(this.card\_image, new Point(0, 0));
}
But it's still not transparent. Do you want to look at my code?
No, I want you to do what I suggested. DON'T put the images inside a control, draw them on your form directly, in your paint event.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Using pictureboxes for this, is a little insane. Just draw your cards onto your form in your paint event.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Christian Graus wrote:
Using pictureboxes for this, is a little insane
ftfy :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.