2012-04-02 3 views
0

현재 C# FTP 클라이언트에서 작업하고 있는데 도움이 필요합니다.C# ListView 행에 아이콘 추가

클라이언트는 FTP 서버에 연결하고 디렉토리를 검색하여 이름을 ListView에 표시합니다.

그러나 Windows 탐색기와 같은 디렉토리/파일에 대한 작은 아이콘을 표시하려고합니다. 너 내가 무슨 말하는지 알지 ...

아무도 도와 줄 수 있습니까? 감사합니다.

LE :

private void listFiles(String path) 
     { 
      connection = (FtpWebRequest)FtpWebRequest.Create(path); 
      connection.Method = WebRequestMethods.Ftp.ListDirectory; 
      WebResponse response = connection.GetResponse(); 
      StreamReader reader = new StreamReader(response.GetResponseStream()); 
      string line = reader.ReadLine(); 
      while (line != null) 
      { 
       listView1.Items.Add(new ListViewItem(line));    
      } 
     } 

나는 무엇을 추가해야합니다 :

지금까지 나는이 방법이 있나요? 나는 C#을 처음 사용했다. ...

+0

일부 샘플 코드를 게시 할 수 있습니까? –

답변

2

imagelist를 추가하고, imagelist를 추가하고, imagelist에 아이콘을 추가하고, ListView.SmallImageList 속성을 imagelist로 설정하고, 행을 '.SmallIconIndex 또는 .SmallIconImageKey (나는 생각한다.) imagelist의 이미지의 인덱스/키.

+1

감사합니다. 나는 당신의 계단을 따라 갔고 모두 잘되었습니다. –

0
If it's a wpf listview you can use the DataTemplate 

<ListView> 
     <ListView.ItemTemplate> 
      <DataTemplate> 
       .. image and <TextBlock> binded to the property you want to show (probably the file name)