Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image in a listview

Status
Not open for further replies.

scoopbh

Programmer
Feb 28, 2003
6
BR
Hi,

I want to put a image in a subitem of a listview, but I wish to put it in the right side of the subitem. I know that the only way to do this is with the oncustomsubitemdraw, but I dont know how to do this.

Also, when we associate a imagelist to listview even if you leave image index of a item as -1 a blank space is created in the first colum before the item text. It's possible to remove it?

A example is welcome.

Thanks in advance.
 
You must use OnDrawItem to remove the space before your item and when you ae drawing the item with the -1 ImageIndex use
Canvas.TextRect(Rect,Rect.Left+1,Rect.Top+1,'your item text');

And for draw a image on the rigth of the items text you can use
//if you want the image on the left too
DefaultDrawing;
or
//if you dont want to
Canvas.TextRect(Rect,Rect.Left+1,Rect.Top+1,'your item text');
//and then
var
Frame:TRect;
begin
Frame:=Rect(Rect.Left+Canvas.TextLength('your item text'),Rect.Top,Rect.Left+Canvas.TextLength('your item text')+yourimagewidth,Rect.Bottom);
Canvas.StretchDraw(Frame,YourImage);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top