关于ListView方面的有关问题
关于ListView方面的问题
我现在在ListView中显示出了一个文件夹下的所有文件和子文件夹,我的问题是
1.怎么才能使双击子文件夹让ListView显示字文件加中的文件,或者双击文件时让其运行。
2当我双击子文件夹进到子文件夹目录中,怎么是他点一个按钮返回到上一层文件夹中。
谢谢各位
------解决方案--------------------
TreeView 和 ListView 配合使用
TreeView 显示,ListView 处理 文件
------解决方案--------------------
//---------------------------------------
struct MyFileStu
{
char FileName[256];
bool IsPath;
int Other;
};
AnsiString CurPath;
void __fastcall TForm1::ViewFolder(AnsiString Path)
{
//ÕâÀïÄãÓ¦¸ÃÒÑʵÏÖ!!!
}
void __fastcall TForm1::ListView1DblClick(TObject *Sender)
{
if(ListView1-> Selected)
{
MyFileStu *P = (MyFileStu *)ListView1-> Selected-> Data;
if(P)
{
if(P-> IsPath)
{
CurPath = P-> FileName;
ViewFolder(CurPath);
}
else ShellExecute( NULL, "open ",P-> FileName,NULL,NULL,SW_SHOW);
}
}
}
//---------------------------------------
void __fastcall TForm1::UpButtonClick(TObject *Sender)
{
CurPath = ExtractFilePath(CurPath);
ViewFolder(CurPath);
}
//---------------------------------------
void __fastcall TForm1::ListView1Insert(TObject *Sender, TListItem *Item)
{
MyFileStu *P = new MyFileStu;
//ÔÚÕâÀï¸øMyFileStuºÏÊʵÄÖµ!!!
Item-> Data = P;
}
//---------------------------------------
void __fastcall TForm1::ListView1Deletion(TObject *Sender, TListItem *Item)
{
if(Item-> Data)
{
delete (MyFileStu *)Item-> Data;
}
}
//---------------------------------------
我现在在ListView中显示出了一个文件夹下的所有文件和子文件夹,我的问题是
1.怎么才能使双击子文件夹让ListView显示字文件加中的文件,或者双击文件时让其运行。
2当我双击子文件夹进到子文件夹目录中,怎么是他点一个按钮返回到上一层文件夹中。
谢谢各位
------解决方案--------------------
TreeView 和 ListView 配合使用
TreeView 显示,ListView 处理 文件
------解决方案--------------------
//---------------------------------------
struct MyFileStu
{
char FileName[256];
bool IsPath;
int Other;
};
AnsiString CurPath;
void __fastcall TForm1::ViewFolder(AnsiString Path)
{
//ÕâÀïÄãÓ¦¸ÃÒÑʵÏÖ!!!
}
void __fastcall TForm1::ListView1DblClick(TObject *Sender)
{
if(ListView1-> Selected)
{
MyFileStu *P = (MyFileStu *)ListView1-> Selected-> Data;
if(P)
{
if(P-> IsPath)
{
CurPath = P-> FileName;
ViewFolder(CurPath);
}
else ShellExecute( NULL, "open ",P-> FileName,NULL,NULL,SW_SHOW);
}
}
}
//---------------------------------------
void __fastcall TForm1::UpButtonClick(TObject *Sender)
{
CurPath = ExtractFilePath(CurPath);
ViewFolder(CurPath);
}
//---------------------------------------
void __fastcall TForm1::ListView1Insert(TObject *Sender, TListItem *Item)
{
MyFileStu *P = new MyFileStu;
//ÔÚÕâÀï¸øMyFileStuºÏÊʵÄÖµ!!!
Item-> Data = P;
}
//---------------------------------------
void __fastcall TForm1::ListView1Deletion(TObject *Sender, TListItem *Item)
{
if(Item-> Data)
{
delete (MyFileStu *)Item-> Data;
}
}
//---------------------------------------