标签:
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { //加载图标到Imagelist Graphics::TBitmap *bmpPicture = NULL; bmpPicture = new Graphics::TBitmap; bmpPicture->LoadFromFile(L"File001.bmp"); ImageList1->Add(bmpPicture,bmpPicture); bmpPicture = new Graphics::TBitmap; bmpPicture->LoadFromFile(L"File002.bmp"); ImageList1->Add(bmpPicture,bmpPicture); bmpPicture = new Graphics::TBitmap; bmpPicture->LoadFromFile(L"File003.bmp"); ImageList1->Add(bmpPicture,bmpPicture); bmpPicture = new Graphics::TBitmap; bmpPicture->LoadFromFile(L"File004.bmp"); ImageList1->Add(bmpPicture,bmpPicture); bmpPicture = new Graphics::TBitmap; bmpPicture->LoadFromFile(L"File005.bmp"); ImageList1->Add(bmpPicture,bmpPicture); bmpPicture = new Graphics::TBitmap; bmpPicture->LoadFromFile(L"File006.bmp"); ImageList1->Add(bmpPicture,bmpPicture); TListColumn *ListColumn; TListItem *ListItem; ListView1->Width = 504; //建立表头信息 ListColumn = ListView1->Columns->Add(); ListColumn->Caption = "姓名"; ListColumn->Width = 100; ListColumn = ListView1->Columns->Add(); ListColumn->Caption = "性别"; ListColumn->Width = 100; ListColumn = ListView1->Columns->Add(); ListColumn->Caption = "年龄"; ListColumn->Width = 100; ListColumn = ListView1->Columns->Add(); ListColumn->Caption = "出生年月"; ListColumn->Width = 100; ListColumn = ListView1->Columns->Add(); ListColumn->Caption = "联系方式"; ListColumn->Width = 100; const char *sex[4]={"男","女"}; //添加信息 ListItem = ListView1->Items->Add(); ListItem->Caption = "李明"; ListItem->ImageIndex = 0; ListItem->SubItems->Add(sex[0]); ListItem->SubItems->Add("23"); ListItem->SubItems->Add("1993-04-11"); ListItem->SubItems->Add("13435987873"); ListItem = ListView1->Items->Add(); ListItem->Caption = "张静"; ListItem->ImageIndex = 1; ListItem->SubItems->Add(sex[1]); ListItem->SubItems->Add("21"); ListItem->SubItems->Add("1991-06-71"); ListItem->SubItems->Add("12345666434"); ListItem = ListView1->Items->Add(); ListItem->Caption = "王红"; ListItem->ImageIndex = 2; ListItem->SubItems->Add(sex[1]); ListItem->SubItems->Add("23"); ListItem->SubItems->Add("1995-01-10"); ListItem->SubItems->Add("13655941178"); ListItem = ListView1->Items->Add(); ListItem->Caption = "孙智铭"; ListItem->ImageIndex = 3; ListItem->SubItems->Add(sex[0]); ListItem->SubItems->Add("24"); ListItem->SubItems->Add("1991-06-11"); ListItem->SubItems->Add("13859878172"); ListItem = ListView1->Items->Add(); ListItem->Caption = "林夕"; ListItem->ImageIndex = 4; ListItem->SubItems->Add(sex[0]); ListItem->SubItems->Add("20"); ListItem->SubItems->Add("1992-02-21"); ListItem->SubItems->Add("13882123378"); ListView1->ViewStyle = vsReport; //ListView1->ViewStyle = vsIcon; //ListView1->ViewStyle = vsList; //ListView1->ViewStyle = vsSmallIcon; ListView1->LargeImages = ImageList1; ListView1->SmallImages = ImageList1; }
效果图:
ViewStyle属性改成csIcon的效果:
TImageList 和 TlistView 组件(C++Builder)
标签:
原文地址:http://www.cnblogs.com/mypsq/p/5071612.html