crashtuak
17-04-2009, 19:11
Вот есть ини файл:
[Options]
CategoryCount=5
ItemsCount=6
[Category]
1=System
2=Video
3=Internet
4=Games
5=Drivers
[Item_1]
name="Item 1"
category=3
[Item_2]
name="Item 2"
category=3
[Item_3]
name="Item 3"
category=4
[Item_4]
name="Item 4"
category=2
[Item_5]
name="Item 5"
category=5
[Item_6]
name="Item 6"
category=1
Потом вот код построения с ини файла дерева:
void __fastcall TForm1::Button4Click(TObject *Sender)
{
int CategoryCount = StrToInt(category->ReadString("Options", "CategoryCount", NULL));
int ItemCount = StrToInt(category->ReadString("Options", "ItemsCount", NULL));
for(int cat = 1; cat <= CategoryCount; cat++) {
TreeView1->Items->Add(NULL,category->ReadString("Category", IntToStr(cat), NULL));
for(int item = 1; item <= ItemCount; item++) {
if(category->ReadString("Item_"+IntToStr(item), "category", NULL) == IntToStr(cat))
{
TreeView1->Items->Add(TreeView1->Items->Item[cat-1],category->ReadString("Item_"+IntToStr(item), "name", NULL));
}
}
}
}
Но при таком коде все сабитемы добавляются не как саб итемы а как хрен знает что :):
http://pic.ipicture.ru/uploads/090417/thumbs/57jivumS4k.jpg (http://ipicture.ru/Gallery/Viewfull/17491734.html)
А надо так:
http://pic.ipicture.ru/uploads/090417/thumbs/T332RBWUM2.jpg (http://ipicture.ru/Gallery/Viewfull/17491829.html)
[Options]
CategoryCount=5
ItemsCount=6
[Category]
1=System
2=Video
3=Internet
4=Games
5=Drivers
[Item_1]
name="Item 1"
category=3
[Item_2]
name="Item 2"
category=3
[Item_3]
name="Item 3"
category=4
[Item_4]
name="Item 4"
category=2
[Item_5]
name="Item 5"
category=5
[Item_6]
name="Item 6"
category=1
Потом вот код построения с ини файла дерева:
void __fastcall TForm1::Button4Click(TObject *Sender)
{
int CategoryCount = StrToInt(category->ReadString("Options", "CategoryCount", NULL));
int ItemCount = StrToInt(category->ReadString("Options", "ItemsCount", NULL));
for(int cat = 1; cat <= CategoryCount; cat++) {
TreeView1->Items->Add(NULL,category->ReadString("Category", IntToStr(cat), NULL));
for(int item = 1; item <= ItemCount; item++) {
if(category->ReadString("Item_"+IntToStr(item), "category", NULL) == IntToStr(cat))
{
TreeView1->Items->Add(TreeView1->Items->Item[cat-1],category->ReadString("Item_"+IntToStr(item), "name", NULL));
}
}
}
}
Но при таком коде все сабитемы добавляются не как саб итемы а как хрен знает что :):
http://pic.ipicture.ru/uploads/090417/thumbs/57jivumS4k.jpg (http://ipicture.ru/Gallery/Viewfull/17491734.html)
А надо так:
http://pic.ipicture.ru/uploads/090417/thumbs/T332RBWUM2.jpg (http://ipicture.ru/Gallery/Viewfull/17491829.html)