How does one create a gradient background for a form? 6 21709
Override OnPaintBackgrou nd and see the LinearGradientB rush help details.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"HenryC" <he***@tste.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. How does one create a gradient background for a form?
Thanks,
I am new to VB and have already read quite a bit without getting it right.
Some code snippet would be nice.
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:eE******** ******@TK2MSFTN GP15.phx.gbl... Override OnPaintBackgrou nd and see the LinearGradientB rush help details.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"HenryC" <he***@tste.com > wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. How does one create a gradient background for a form?
Stick this behind the form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e)
Dim baseBackground As System.Drawing. Drawing2D.Linea rGradientBrush
baseBackground = New LinearGradientB rush(New Point(0, 0), _
New Point(ClientSiz e.Width, 0), _
Color.Blue, _
Color.Red)
e.Graphics.Fill Rectangle(baseB ackground, ClientRectangle )
End Sub
"HenryC" <he***@tste.com > wrote in message
news:uW******** ******@TK2MSFTN GP14.phx.gbl... Thanks, I am new to VB and have already read quite a bit without getting it right. Some code snippet would be nice.
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message news:eE******** ******@TK2MSFTN GP15.phx.gbl... Override OnPaintBackgrou nd and see the LinearGradientB rush help details.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"HenryC" <he***@tste.com > wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. > How does one create a gradient background for a form? > >
Thanks John
"JohnFol" <Ou************ @WibbleObbble.C om> wrote in message
news:4v******** **********@news fe6-gui.ntli.net... Stick this behind the form Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint( e)
Dim baseBackground As System.Drawing. Drawing2D.Linea rGradientBrush
baseBackground = New LinearGradientB rush(New Point(0, 0), _
New Point(ClientSiz e.Width, 0), _
Color.Blue, _
Color.Red)
e.Graphics.Fill Rectangle(baseB ackground, ClientRectangle )
End Sub
"HenryC" <he***@tste.com > wrote in message news:uW******** ******@TK2MSFTN GP14.phx.gbl... Thanks, I am new to VB and have already read quite a bit without getting it
right. Some code snippet would be nice.
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message news:eE******** ******@TK2MSFTN GP15.phx.gbl... Override OnPaintBackgrou nd and see the LinearGradientB rush help
details. -- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"HenryC" <he***@tste.com > wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. > How does one create a gradient background for a form? > >
Thanks Bob,
I went to your site and got the code snippet I needed.
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:eE******** ******@TK2MSFTN GP15.phx.gbl... Override OnPaintBackgrou nd and see the LinearGradientB rush help details.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"HenryC" <he***@tste.com > wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. How does one create a gradient background for a form?
Henry,
In addition to the other comments.
I've set the BackgroundImage of the from to an image that was painted with a
gradient brush, something like:
Protected Overrides Sub OnLayout(ByVal e As LayoutEventArgs )
MyBase.OnLayout (e)
If Not Me.BackgroundIm age Is Nothing Then
If Size.op_Equalit y(Me.Background Image.Size, Me.ClientSize) Then
Exit Sub
End If
Me.BackgroundIm age.Dispose()
Me.BackgroundIm age = Nothing
End If
Dim rect As New Rectangle(New Point(0, 0), Me.ClientSize)
Dim image As New Bitmap(Me.Clien tSize.Width, Me.ClientSize.H eight)
Dim gr As Graphics = Graphics.FromIm age(image)
Dim brush As New LinearGradientB rush(rect,
ControlPaint.Li ghtLight(Me.Bac kColor), Me.BackColor,
LinearGradientM ode.Vertical)
brush.SetBlendT riangularShape( 2 / 3)
gr.FillRectangl e(brush, rect)
gr.Dispose()
brush.Dispose()
Me.BackgroundIm age = image
End Sub
Hope this helps
Jay
"HenryC" <he***@tste.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| How does one create a gradient background for a form?
|
| This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert W. |
last post by:
In my Winforms app I'm trying to get an image's background to appear
transparent on a form that has a gradient background. So I added a
PictureBox and then attempted to add a custom paint command for the
PictureBox. But it's not working. Here's the code I've written:
public void InitializeLinearGradients()
{
this.Paint += new PaintEventHandler(PaintClient);
this.SizeChanged += new EventHandler(SizeClient);
pictureLogo.Paint += new...
|
by: Wayne Wengert |
last post by:
I'm looking for information or samples of how to display a gradient
background color for an ASP.NET web page. I want to be able to set a start
and end color (e.g. Light Orange to White) and have the page rendered with
that gradient background from left to right. Using google I found several
examples but they all appeared to apply only to Windows Forms
Wayne
|
by: Don |
last post by:
I'm making a custom control that has a multiline textbox on it. I want to
make the textbox have a gradient background. On my custom control's Paint
event I call a routine that draws a gradient on the textbox's background,
but the gradient starts appearing at the bottom of the textbox after the
last line of text. It's almost as if VB draws the gradient on the entire
textbox, then blanks out the part of the textbox that actually displays...
|
by: David Gouge |
last post by:
Hi All, appreciate that this is more gdi+ than c# but always seem to get
good answers here, so here goes...
In a nutshell, all i want to do is add a gradient background to a
ListView. I have gotten so far by:
Adding the following to the constructor:
this.SetStyle(ControlStyles.UserPaint, true);
|
by: madladuk |
last post by:
Hi all.
Does anyone have any example of how to do a gradient background whilst
moving over graphics and text like the Microsoft web site. On the MS site
when you select an area a window popup and as you hover over the sections it
fill in a nice gradient background, any assistance?
Thanks
| |
by: moondaddy |
last post by:
I want to fill the entire background of a page with a gradient. As a test,
I first filled with a solid color like this:
<body style="background-color: #ccffff;" >
and the entire page was this color.
next I replaced that with a gradient style like this:
<body style="filter:
|
by: Eric Lindsay |
last post by:
How do you provide a consistent gradient fill as a background in a
liquid layout?
If I make a gradient fill image say 1000 pixels wide (and repeat it down
the page) to suit a typical computer display, then only a small portion
of the gradient will show if the viewpoint is a smaller PDA or phone
display.
On the other hand, if viewed full screen on a 1920 pixel wide display, I
would run out of gradient on one or both sides of the page....
|
by: Bryon |
last post by:
My current code paints a rectangular area at the top (under the menu and
tool strip) and bottom (top of the status strip) of the main form with a
linear gradient. The problem is that when the form is resized or maximized
for that matter, the form still displays the last areas that were painted
with gradient. Basically the form does not erase the last graphics that
were painted to the form and just paints over it with the new. My code is...
|
by: Bob Altman |
last post by:
Hi all,
Here's another rank beginner question. What is the standard way to fill a
client-side table cell with a horizontal gradient background?
TIA - Bob
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |