XE7 ListView automatically calculates row heights

Source: Internet
Author: User

Description: Displays a ListView that automatically adjusts the height of the Detail string length for each row of Item (each row can be of different heights).

Applicable: Delphi XE7

SOURCE download: [Original]listview_ automatic calculation line height (by Tortoise Mountain a swastika). zip

procedureTform1.button1click (sender:tobject);ConstDETAILSTR:Array[0..2] ofString =('1234567890123456789012345678901234567890123456789012345678901234567890','abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz','abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz');varI, R:integer; Item1:tlistviewitem;begin      fori:=0  to  -  Do     beginItem1:=ListView1.Items.Add; R:= Random (3); Item1.detail:= Detailstr[r]. Substring (0, Random (Detailstr[r].          Length)); Item1.text:=i.tostring; End;End;procedureTform1.listview1updateobjects (ConstSender:tobject; Constaitem:tlistviewitem);varR:TRECTF;begin     if(AItem.Objects.DetailObject <>Nil) and(AItem.Objects.DetailObject.Text<>"') Then     begin          //calculate the area of text displayR: = RECTF (0,0, AItem.Objects.DetailObject.Width,10000); ListView1.Canvas.MeasureText (R, AItem.Objects.DetailObject.Text, AItem.Objects.DetailObject.WordWrap          , [], ttextalign.leading, ttextalign.leading); //Set HeightAitem.height: =Trunc (r.height); End;End;

XE7 ListView automatically calculates row heights

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.