I'm using TListView in my form (which inherits from TCustomListView) and when I change ListView style to "vsSmallIcon" the icons gets badly arranged. We found this issue ever since we ported our Code from Borland 2006 to XE4. Rest all "ViewStyle"s like vsIcon, vsList & vsReport are working fine. Did anyone faced similar issue with VCL's TlistView component? I have already tried ListView1->Arrange(arDefault) and 'AutoArrange' Icon Options but nothing seems to work for 'vsSmallIcon' TViewStyle.
I'm on Windows 7 and using RAD Studio XE4 with Update1.
Thanks,
Santosh Thankachan
PS: Added an image to show this issue with vsSmallIcon TViewStyle.
Code is as follows:
//SmallIconIssue.h
#ifndef SmallIconsIssueH
#define SmallIconsIssueH
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ImgList.hpp>
#include <Vcl.ComCtrls.hpp>
class TSmallIconTest : public TForm
{
__published: // IDE-managed Components
TImageList *ImageList1;
TComboBox *ComboBox1;
TListView *ListView1;
TLabel *Label1;
void __fastcall FormCreate(TObject *Sender);
void __fastcall ComboBox1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TSmallIconTest(TComponent* Owner);
};
extern PACKAGE TSmallIconTest *SmallIconTest;
#endif
//SmallIconIssue.cpp
#pragma package(smart_init)
#pragma resource "*.dfm"
TSmallIconTest *SmallIconTest;
__fastcall TSmallIconTest::TSmallIconTest(TComponent* Owner) : TForm(Owner) {}
void __fastcall TSmallIconTest::FormCreate(TObject *Sender) {
const char Names[42][2][10] =
{{"Rubble","Barny"},
{"Michael", "Johnson"},
{"Bunny", "Bugs"},
{"Silver", "HiHo"},
{"Silver1", "HiHo1"},
{"Silver2", "HiHo2"},
{"Silver3", "HiHo3"},
{"Silver4", "HiHo4"},
{"Silver5", "HiHo5"},
{"Silver6", "HiHo6"},
{"Silver7", "HiHo7"},
{"Silver8", "HiHo8"},
{"Silver9", "HiHo9"},
{"Silver11", "HiHo11"},
{"Silver22", "HiHo22"},
{"Silver33", "HiHo33"},
{"Silver44", "HiHo44"},
{"Silver55", "HiHo55"},
{"Silver66", "HiHo66"},
{"Silver77", "HiHo77"},
{"Simpson1", "Bart1"},
{"Simpson2", "Bart2"},
{"Simpson3", "Bart3"},
{"Simpson4", "Bart4"},
{"Simpson5", "Bart5"},
{"Simpson6", "Bart6"},
{"Simpson7", "Bart7"},
{"Simpson8", "Bart8"},
{"Simpson9", "Bart9"},
{"Simpson11", "Bart11"},
{"Simpson22", "Bart22"},
{"Simpson33", "Bart33"},
{"Simpson44", "Bart44"},
{"Simpson55", "Bart55"},
{"Simpson66", "Bart66"},
{"Simpson77", "Bart77"},
{"Simpson88", "Bart88"},
{"Simpson99", "Bart99"},
{"Simpson00", "Bart00"},
{"Simpson12", "Bart12"},
{"Simpson13", "Bart13"},
{"Squirrel", "Rocky"}};
TListItem *Item;
TListColumn *Column;
const char imagenames[30][30] = {
"Borland2 Image akjlhfkja",
"Borland3 Imagewerq r",
"Borland4 Rest qew reqwr",
"Borland5 Imagedf fa",
"Borland6 Free df ",
"Borland7 Image af ",
"Borland8 Clear ad3e",
"Borland9 Image123 ",
"Borland11 df d",
"Borland22 Imagea fa f",
"Borland33 hmmm f sdf f",
"C++ Image",
"Borland1 Test",
"Borland44 Imageq3r r",
"Borland55 abcdefg rest",
"Borland66 Imageq tr trt",
"Borland77 no rest atall dg",
"Borland88 Imageqtree",
"Borland99 Free VCL tree",
"Borland12 Imagedf fa",
"Borland23 Blurr df d",
"Borland34 r",
"Borland45 Rest qew reqwr",
"Borland56 Free df ",
"Borland67 Image123 ",
"Borland78 Imagea fa f",
"Borland89 Being",
"Borland90 AdFree",
"Borland13 Image akjlhfkja",
"Delphi23 Image color"
};
const char Col2Array[30][60] =
{
"Documentation for the C++ icon.",
"Borland1 icon test.",
"Borland2 icon. Rest sar",
"Borland3 icon Free .",
"Borland4 icon Tree. af",
"Borland6 icon Kree kjadsf k.",
"Borland7 icon lest hghghg.",
"Borland8 icon mnmnm.",
"Borland9 icon jiop werq .",
"Borland0 icon terere df af .",
"Borland5 icon nmijh fdferfr .",
"Borland11 icon Clear vc.",
"Borland22 icon Image sdgfsdg.",
"Borland33 icon Picture t4.",
"Borland44 iconv Congress25245.",
"Borland55 icon Labor 25v545.",
"Borland66 icon tony b3764656.",
"Borland77 icon 5 Abott reg354.",
"Borland88 icon. Rest sar",
"Borland99 icon Kevin 342455vreg354.",
"Borland00 icon test.",
"Borland12 icon Free .",
"Borland23 icon Kree kjadsf k.",
"Borland34 con Tree. af",
"Borland56 icon nmijh fdferfr .",
"Borland45 icon mnmnm.",
"Borland56 icon jiop werq .",
"Borland78 icon terere df af .",
"Borland89 icon lest hghghg.",
"Delphi90 icon Rudd 45c rewffretew."
};
ListView1->SmallImages = ImageList1;
ListView1->LargeImages = ImageList1;
for (int i = 0; i < ImageList1->Count; i++)
{
Item = ListView1->Items->Add();
Item->Caption = imagenames[i];
Item->ImageIndex = i;
Item->SubItems->Add(Col2Array[i]);
}
// Create two columns to show during viewing as vsReport
Column = ListView1->Columns->Add();
Column->Caption = "Image Name";
Column->Width = 200;
Column = ListView1->Columns->Add();
Column->Caption = "Image Description";
Column->Width = 200;
// Add View styles and constants to the Combo Box
ComboBox1->Items->AddObject("vsIcon", reinterpret_cast<TObject *>(vsIcon));
ComboBox1->Items->AddObject("vsList", reinterpret_cast<TObject *>(vsList));
ComboBox1->Items->AddObject("vsReport", reinterpret_cast<TObject *>(vsReport));
ComboBox1->Items->AddObject("vsSmallIcon", reinterpret_cast<TObject *>(vsSmallIcon));
// Display First item in the Combo Box and arrange ListView accordingly...
ComboBox1->ItemIndex = 0;
ListView1->ViewStyle = (TViewStyle) ComboBox1->Items->Objects[ComboBox1->ItemIndex];
ListView1->Arrange(arDefault);
}
void __fastcall TSmallIconTest::ComboBox1Click(TObject *Sender)
{
ListView1->ViewStyle = (TViewStyle) ComboBox1->Items->Objects[ComboBox1->ItemIndex];
ListView1->Arrange(arDefault);
}
ListView.Arrange(arDefault);
in f.i.OnCreate
of your form, also be sure to haveIconOptions.AutoArrange
'true' for when you're deleting an item etc.. Does it help? – Sluff