X
Xafier
Hi,
I'm creating a control that overrides ListView and so I'm working on
redrawing everything myself with some changes here and there...
But I'm having a problem with drawing the text inside the rectangle on
LargeIcon mode... I thought I'd finally discovered the solution with
TextRenderer but this still doesn't give the correct results.
Here's the code I'm trying to use (item is a ListViewItem)
Rectangle text_rect = item.GetBounds(ItemBoundsPortion.Label);
TextFormatFlags formatFlags = TextFormatFlags.WordBreak |
TextFormatFlags.HorizontalCenter | TextFormatFlags.Top |
TextFormatFlags.EndEllipsis;
if (item.Text != null && item.Text.Length > 0)
TextRenderer.DrawText(dc, item.Text, item.Font, text_rect,
item.ForeColor, item.BackColor, formatFlags);
The problem is that its still not exactly what the original ListView
displays... ie
I'm displaying:
___________
| some |
| really long |
original ListView displays:
___________
| some really |
| long text |
Surely it should fit inside the bounding box if its using the GDI draw
method and I'm using the bounding box thats returned to me from the
ListViewItem itself? Any ideas?
thanks
Kris Wragg
I'm creating a control that overrides ListView and so I'm working on
redrawing everything myself with some changes here and there...
But I'm having a problem with drawing the text inside the rectangle on
LargeIcon mode... I thought I'd finally discovered the solution with
TextRenderer but this still doesn't give the correct results.
Here's the code I'm trying to use (item is a ListViewItem)
Rectangle text_rect = item.GetBounds(ItemBoundsPortion.Label);
TextFormatFlags formatFlags = TextFormatFlags.WordBreak |
TextFormatFlags.HorizontalCenter | TextFormatFlags.Top |
TextFormatFlags.EndEllipsis;
if (item.Text != null && item.Text.Length > 0)
TextRenderer.DrawText(dc, item.Text, item.Font, text_rect,
item.ForeColor, item.BackColor, formatFlags);
The problem is that its still not exactly what the original ListView
displays... ie
I'm displaying:
___________
| some |
| really long |
original ListView displays:
___________
| some really |
| long text |
Surely it should fit inside the bounding box if its using the GDI draw
method and I'm using the bounding box thats returned to me from the
ListViewItem itself? Any ideas?
thanks
Kris Wragg