473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ListView with Gradient Background

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);

And then overriding OnPaintBackground with the following:

protected override void OnPaintBackground(PaintEventArgs pevent)
{
Graphics g = pevent.Graphics;
Rectangle rBackground = new Rectangle(0, 0, this.Width, this.Height);

System.Drawing.Drawing2D.LinearGradientBrush bBackground = new
System.Drawing.Drawing2D.LinearGradientBrush(rBack ground,
Color.LightGoldenrodYellow, Color.White, (float)90);

g.FillRectangle(bBackground, rBackground);
}

Which works to a point; the listview has a nice gradient background, but
when items are added to the listview they do not show up and
subsequently when the listview is scrolled, the gradient gets 'messed
up'. I do not want to do anything special with the listview items
themselves, and as i scroll i would expect the gradient to stay put.

Complete beginner at gdi+, so any pointers / help would be appreciated.

Cheers,

Dave
Sep 21 '06 #1
0 3014

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Woody Splawn | last post by:
I have a webform where I would like to have the background color for the webform be a gradient in blue. How do I do this? What is the easiest way? What is the way most used by other developers? ...
0
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...
2
by: Dean Slindee | last post by:
It appears that I have two routines that don't play well together! First routine: a form's background is shaded with a gradient color. Second routine: then, the background of all labels on the...
2
by: Padu | last post by:
I'm looking for a component to make listviews (perhaps grid). I have two requirements for the component for two different situations I want to use it. In the first situation, I need a listview...
0
by: Dan Baumbach | last post by:
I'm working on a toolbar for IE. I have everything working well but I'm unable to get the toolbar to have the same gradient background under XP that other toolbars on IE have. To start with, I...
1
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...
5
by: R | last post by:
Minimizing an app that uses a ListView in a custom control causes all entries in the ListView to disappear, never to return. What would affect this?
6
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...
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.