Language Reference Guide : System Classes : ListviewColAttr Class
 
Share this page          
ListviewColAttr Class
The ListviewColAttr class specifies the properties of columns of a ListviewField. An object of this class is needed for each column. The ColAttributes attribute of the ListviewField class contains the reference to an array of ListviewColAttr objects that describes the columns of the ListviewField.
The following is a programming example using the ListviewColAttr class:
initialize =
declare
          lv = ListViewField;
          str12 = StringObject;
          str22 = StringObject;
          str23 = StringObject;
          smallicon = BitmapObject;
          largeicon = BitmapObject;
enddeclare
begin
/* Assign the parent field. This is necessary to
make the ListviewField visible in the frame. */
          lv.ParentField = Curframe.Topform;
/* Set up the width and height of the ListviewField (lv) */
          lv.Width = 3500;
          lv.Height = 1500;
/* Load the two bitmap objects from disk files and
insert them into the appropriate image lists */
          smallicon.FileHandle = 'small.ico';
          lv.SmallImageList[1] = smallicon;
          largeicon.FileHandle = 'large.ico';
          lv.LargeImageList[1] = largeicon;
/* Set up the widths of each of the columns. Use the
feature of dynamic array to indicate number of
columns the ListviewField will have */
          lv.ColAttributes[1].ColumnWidth = 1500;
          lv.ColAttributes[2].ColumnWidth = 1000;
          lv.ColAttributes[3].ColumnWidth = 1000;
/* Assign the header text to the columns */
          lv.ColAttributes[1].HeaderText = 'Column 1';
          lv.ColAttributes[2].HeaderText = 'Column 2';
          lv.ColAttributes[3].HeaderText = 'Column 3';
/*
Insert text for each row (item). Also use the
feature of dynamic array for number of rows. Notice
that text for the first column goes in EnumDisplay
while the text for the subsequent columns goes in
EnumSubText array. The first element of this array
corresponds to the second column.
*/
          /* use the 1st icon in the image lists for the 1st row */
          lv.ValueList.ChoiceItems[1].ImageIndex = 1;
          lv.ValueList.ChoiceItems[1].EnumDisplay = 'item 1 col1';
          str12.value = 'item 1 col 2';
          lv.ValueList.ChoiceItems[1].EnumSubText[1] = str12;
          lv.ValueList.ChoiceItems[2].ImageIndex = 0;
          /* no icon for the second row */
          lv.ValueList.ChoiceItems[2].EnumDisplay = 'item 2 col 1';
          str22.value = 'item 2 col 2';
          lv.ValueList.ChoiceItems[2].EnumSubText[1] = str22;
          str23.value = 'item 2 col 3';
          lv.ValueList.ChoiceItems[2].EnumSubText[2] = str23;
/* Update the display with the current data values */
          lv.UpdChoicelist();
end
/* Change the display style according to the user's choice */
on click menu.view.largeicons =
begin
          lv.Style = LVFS_ICON;
end
on click menu.view.smallicons =
begin
          lv.Style = LVFS_SMALLICON;
end
on click menu.view.list =
begin
          lv.Style = LVFS_LIST;
end
on click menu.view.details =
begin
          lv.Style = LVFS_DETAIL;
end
Inherits From
Object Class
Inherited By
EnumField
Attributes
ColumnWidth
HeaderText
TextAlignment
Methods
None