S
Sin Jeong-hun
What I am trying to do is quite simple (at least I thought so). I want
to render the first column by myself, and all other parts to be drawn
normally.
For example, I just wanted to draw the ID column by myself, and Col 1,
Col 2 normally (default drawing)
---------------------------
| ID | Col 1 | Col 2 | <-Column headers
---------------------------
| 1 | a | b |
| 2 | | |
| 3 | a | |
| 4 | a | b |
--------------------------
I wanted make it a class so the code was like:
protected override void
OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
{
e.DrawDefault = true;
}
protected override void
OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex ==0 )
{
e.Graphics.FillRectangle(new LinearGradientBrush(new
Point(0, 0), new Point(5, 5), Color.Red, Color.White), e.Bounds);
e.DrawText();
}
else
{
e.DrawDefault = true;
}
}
It didn't work! For each item, e.ColumIndex == 0 was called twice, and
I don't know why. and the code above also fills Col1 and Col2 of ID 2.
Those columns are null (no items). I just want to draw the first
column myself and leave all others alone, I don't know why that
seemingly simple task is so difficult. After spending a lot of hours
searching Google and writing and scratching codes, I came here to ask
for some help.
to render the first column by myself, and all other parts to be drawn
normally.
For example, I just wanted to draw the ID column by myself, and Col 1,
Col 2 normally (default drawing)
---------------------------
| ID | Col 1 | Col 2 | <-Column headers
---------------------------
| 1 | a | b |
| 2 | | |
| 3 | a | |
| 4 | a | b |
--------------------------
I wanted make it a class so the code was like:
protected override void
OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
{
e.DrawDefault = true;
}
protected override void
OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex ==0 )
{
e.Graphics.FillRectangle(new LinearGradientBrush(new
Point(0, 0), new Point(5, 5), Color.Red, Color.White), e.Bounds);
e.DrawText();
}
else
{
e.DrawDefault = true;
}
}
It didn't work! For each item, e.ColumIndex == 0 was called twice, and
I don't know why. and the code above also fills Col1 and Col2 of ID 2.
Those columns are null (no items). I just want to draw the first
column myself and leave all others alone, I don't know why that
seemingly simple task is so difficult. After spending a lot of hours
searching Google and writing and scratching codes, I came here to ask
for some help.