473,480 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Custom ListView problem

I just started to create my own ListView control and already have big problems...

I use the following code at the moment:

protected override void OnPaint(PaintEventArgs pe)
{
this.SuspendLayout();
if (this.View == View.Details)
{
Graphics g = pe.Graphics;
g.Clear(this.BackColor);
foreach (ListViewItem lvi in this.Items)
{
if (lvi.Selected)
g.FillRectangle(new SolidBrush(Color.LightBlue), lvi.Bounds);
g.DrawString(lvi.Text, lvi.Font, new SolidBrush(lvi.ForeColor), lvi.Bounds, StringFormat.GenericDefault);
}
}

this.ResumeLayout();
// Calling the base class OnPaint
base.OnPaint(pe);
}

The curious problem now is that everything works as expected EXPECT the first item!
I can click on it as often as I want and it´s value is selected but nevertheless, no blue rectangle is drawn...

But resizing the columns of the detail ListView brings up the blue rectangle or if the custom ListView loses
focus, the rectangle is painted too.

Can someone explain me that (in my eyes) strange behavior?
A big thanks to you!

Greetings,
timtos.
Nov 15 '05 #1
0 1233

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

Similar topics

7
12482
by: Martin Schulze | last post by:
Hello, i tried to compose myself a custom usercontrol which is derieved from System.Windows.Forms.UserControl. It contains 2 comboboxes and one textbox (which are also custom controls, but...
0
1630
by: sorpor | last post by:
I am trying to create a custom listviewsorter by implementing IComparer. My listview has check boxes and the purpose is to move checked item to top of list. They all will be sorted ascendingly. It...
1
1483
by: Jeff | last post by:
I've made a custom Listview control, and i want this control to use a custom ColumnHeader control that I've created. how can i do this thanks
5
5822
by: ToddH | last post by:
I know the following code is C#. I'm a vb programmer trying to learn a new language. I posted this in the c# group but never got a response. You guys seem to know alot about all languages and have...
5
1131
by: jerem22 | last post by:
Hi there, In my application, I would like to use a custom ListView control. In order to do that, I've created a new class that inherit ListView and basically looks like this : class...
7
5076
by: =?Utf-8?B?YnJhaW5mdWVsbWVkaWE=?= | last post by:
Can anyone point me in the direction of creating a custom listview item? I guess the other question then - is this possible? I want to create a list of listview items comprised each comprised of...
1
2649
by: a | last post by:
Hi I would like to add some additional custom features to the listview, like cell editing. The created object will be added to the form as part of the GUI, and it should be able to handle...
0
897
by: cordov | last post by:
Hi everyone, I create the ghost image using the exellent article from http://www.codeproject.com/KB/miscctrl/Ghost_drag_image.aspx?print=true The problem is when I use a custom listview or just...
1
1585
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
I'm running VS2008 & attempting to solve a problem I've encountered while developing some software for our business. Here's the basic idea...I've created a class that represents a file (with...
0
6904
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
7034
Oralloy
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,...
0
7076
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...
1
6732
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...
0
5324
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
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
174
bsmnconsultancy
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...

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.