Is there something wrong with my Code, or do I need to override on other
control to capture the paint event?
Here my Code:
public class ListView4I : System.Windows.Forms.ListView
{
protected override void OnPaint( PaintEventArgs e)
{
MessageBox.Show("Painting is running...");
base.OnPaint( e );
}
}
thx surech
HTH mike
"Stefan Urech" <s.urech@[NOSPAM]fiveinfo.ch> schrieb im Newsbeitrag
news:b27kjs$ofm$1...@rex.ip-plus.net...
Mike Barthold schrieb:
mike
"Stefan Urech" <s.urech@[NOSPAM]fiveinfo.ch> schrieb im Newsbeitrag
news:b27pvc$ofm$3...@rex.ip-plus.net...
Ok, that's no problem when i fill the ListView like this:
if ((lsvListe.Items.Count % 2) == 0)
listItem.BackColor = Color.FromArgb(206, 253, 206);
lsvListe.Items.Add( listItem );
But now i like to make my own ListView, which do that automatic.
That with the OnPaint-Method-Overriding was only an idea, i'm not sure,
if it would work...
Mike Barthold schrieb:
I solved this with another idea -> my intention was to easily publish a
datatable object to a listview.
dynamically, this means, i dont know the datatypes, column-count, etc. so I
enhanced the listview class with a "Publish" method giving it a datatable or
dataview object as a parameter.
This publish method does exactly that, what you have written here (i % 2 ==
0)...
it works fine for me.
Since the listview has no paint event its the only way to do it, except you
hook on the base messagequeue of the control and try to grep that WM_PAINT
message... (I always try to avoid such lowlevel things and keep using the
interfaces that are provided to me from .net).
If you don't want to change the interface of the listview by enhancing it
with a publish method you will have to hook.
HTH mike
"Stefan Urech" <s.urech@[NOSPAM]fiveinfo.ch> schrieb im Newsbeitrag
news:b27s3v$ofm$4...@rex.ip-plus.net...
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
int i = 0;
// WM-Paint abfangen
if (m.Msg == 0x000F)
{
foreach( ListViewItem item in this.Items)
{
if(i++ % 2 == 0) item.BackColor = Color.LightBlue;
}
}
}
As you said, it's goes a little bit too deep. But hey, it works!
thx and cu surech
Mike Barthold schrieb: