Click here to Skip to main content
11,637,176 members (70,778 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0 C#3.5
I'm Drawing Rectangle using `Grahpics` Class(GDI+).
And I have set the form's opacity to 30%.

this is my code.
            Graphics gr = e.Graphics;
            Pen pen = new Pen(new SolidBrush(Color.FromArgb(255,Color.Red)),1);
            gr.DrawRectangle(pen, rect);
but.. Pen Opacity is 30% too!

I'm so want the original color.

how can i do?
Posted 6-Sep-11 0:36am
Edited 6-Sep-11 22:42pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It's not possible with windows forms. A partially transparent form cannot have opaque controls (or drawings). You could use two form approach, one fully transparent with opaque controls over another partially transparent form. You can also use windows transparency key of opaque form to hide unwanted area Or Use simply use WPF. Hope this helps
rus204 at 6-Sep-11 10:03am
thnx, and.. how can i do that in WPF? no example?
nikhilbdamle at 10-Sep-11 4:27am
Check the below link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 stibee 313
1 295
2 OriginalGriff 295
3 himanshu agarwal 184
4 Sergey Alexandrovich Kryukov 154
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,513
2 Mika Wendelius 6,922
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 7 Sep 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100