Use the tlistview control (3)

Source: Internet
Author: User
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, comctrls; Type tform1 = Class (tform) listview1: tlistview; button1: tbutton; button2: tbutton; checkbox1: tcheckbox; checkbox2: tcheckbox; Procedure success (Sender: tobject); Procedure button2click (Sender: tobject ); procedure checkbox1click (Sender: tobject); Procedure checkbox2click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); var I: integer; column: tlistcolumn; begin for I: = 0 to 5 do begin column: = listview1.columns. add; column. caption: = format ('col % d', [I]); end; listview1.align: = altop; listview1.viewstyle: = vsreport; listview1.gridlines: = true; {non-default} listview1.showcolumnheaders: = true; {default} checkbox1.caption: = 'gridlines '; checkbox2.caption: = 'showcolumnheaders'; checkbox1.checked: = true; checkbox2.checked: = true; button1.caption: = 'add'; button2.caption: = 'clear'; end; Procedure tform1.button1click (Sender: tobject); var item: tlistitem; I: integer; begin item: = listview1.items. add; item. caption: = 'item' + inttostr (item. index); for I: = 0 to listview1.columns. count-1 do item. subitems. add (format ('% d % d', [item. index, I]); end; Procedure tform1.button2click (Sender: tobject); begin listview1.items. clear; end; Procedure tform1.checkbox1click (Sender: tobject); begin listview1.gridlines: = checkbox1.checked; end; Procedure finished (Sender: tobject); begin finished: = checkbox2.checked; end.
 
   
 

Form file:

Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 198 clientwidth = 322 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false oncreate = formcreate pixelsperinch = 96 textheight = 13 object listview1: tlistview left = 8 Top = 8 width = 185 Height = 121 columns = taborder = 0 end object button1: tbutton left = 232 Top = 134 width = 75 Height = 25 caption = 'button1' taborder = 1 onclick = button1click end object button2: tbutton left = 232 Top = 165 width = 75 Height = 25 caption = 'button2' taborder = 2 onclick = button2click end object checkbox1: tcheckbox left = 16 Top = 145 width = 97 Height = 17 caption = 'checkbox1' taborder = 3 onclick = checkbox1click end object checkbox2: tcheckbox left = 16 Top = 169 width = 177 Height = 17 caption = 'checkbox2 'taborder = 4 onclick = checkbox2click endend
 
  
 

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.