Click here to Skip to main content
15,893,904 members
Home / Discussions / C#
   

C#

 
GeneralRe: Program crashes when form is refreshed Pin
Member 127487831-Nov-17 10:38
Member 127487831-Nov-17 10:38 
QuestionIssue with WPF C# Treeview GetFiles Pin
Member 1348136124-Oct-17 8:08
Member 1348136124-Oct-17 8:08 
SuggestionRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming24-Oct-17 9:49
mveRichard Deeming24-Oct-17 9:49 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136124-Oct-17 10:01
Member 1348136124-Oct-17 10:01 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming25-Oct-17 1:50
mveRichard Deeming25-Oct-17 1:50 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136125-Oct-17 3:09
Member 1348136125-Oct-17 3:09 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming25-Oct-17 3:31
mveRichard Deeming25-Oct-17 3:31 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136125-Oct-17 9:21
Member 1348136125-Oct-17 9:21 
Richard,
Thank you for your feedback. The code you gave works fine. However, I'm not clear on your recent message regarding ListViewItem.
My Drives, Folders and subfolders appear in the Treeview (Left Panel) and I want the Files to appear in the ListView (Right Panel). So I'm not clear what you are suggesting. In the code below I try what I think you are saying but Header is not contained in ListViewItem. Can you explain further?

void folder_Expanded(object sender, RoutedEventArgs e)
       {

           TreeViewItem item = (TreeViewItem)sender;
           if (item.Items.Count == 1 && item.Items[0] == dummyNode)
           {
               item.Items.Clear();
               try
               {
                   string path = item.Tag.ToString();
                   txtPath.Text = path;
                   listView1.Items.Clear();
                   foreach (string dir in Directory.GetDirectories(path))
                   {
                       TreeViewItem subitem = new TreeViewItem();
                       subitem.Header = new DirectoryInfo(dir).Name;
                       subitem.Tag = dir;
                       subitem.FontWeight = FontWeights.Normal;
                       subitem.Items.Add(dummyNode);
                       subitem.Expanded += folder_Expanded;
                       item.Items.Add(subitem);

                   }

                   foreach (string file in Directory.GetFiles(path))
                   {
                       ListViewItem fileitem = new ListViewItem();
                       fileitem.Header = new DirectoryInfo(file).Name;
                       fileitem.Tag = file;
                       fileitem.FontWeight = FontWeights.Normal;
                       listView1.Items.Add(fileitem);
                   }

GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming26-Oct-17 1:26
mveRichard Deeming26-Oct-17 1:26 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136126-Oct-17 9:46
Member 1348136126-Oct-17 9:46 
Questioncrystal reports prompt login information Pin
Member 1341707224-Oct-17 2:46
Member 1341707224-Oct-17 2:46 
AnswerRe: crystal reports prompt login information Pin
Afzaal Ahmad Zeeshan24-Oct-17 3:31
professionalAfzaal Ahmad Zeeshan24-Oct-17 3:31 
QuestionWhat am i supposed to use Pin
A.Mr.Nice.Guy23-Oct-17 20:40
A.Mr.Nice.Guy23-Oct-17 20:40 
AnswerRe: What am i supposed to use Pin
Mycroft Holmes23-Oct-17 22:06
professionalMycroft Holmes23-Oct-17 22:06 
AnswerRe: What am i supposed to use Pin
OriginalGriff23-Oct-17 22:16
mveOriginalGriff23-Oct-17 22:16 
GeneralRe: What am i supposed to use Pin
Jim_Snyder27-Oct-17 4:49
professionalJim_Snyder27-Oct-17 4:49 
QuestionMessage Closed Pin
22-Oct-17 21:03
Gregan Dark22-Oct-17 21:03 
AnswerRe: win6x_registry_tweak PinPopular
Pete O'Hanlon22-Oct-17 22:56
mvePete O'Hanlon22-Oct-17 22:56 
GeneralRe: win6x_registry_tweak Pin
Gregan Dark23-Oct-17 2:57
Gregan Dark23-Oct-17 2:57 
GeneralRe: win6x_registry_tweak Pin
Dave Kreskowiak23-Oct-17 4:36
mveDave Kreskowiak23-Oct-17 4:36 
GeneralRe: win6x_registry_tweak Pin
Gregan Dark23-Oct-17 9:23
Gregan Dark23-Oct-17 9:23 
GeneralRe: win6x_registry_tweak Pin
Dave Kreskowiak23-Oct-17 9:48
mveDave Kreskowiak23-Oct-17 9:48 
GeneralRe: win6x_registry_tweak Pin
Pete O'Hanlon23-Oct-17 9:55
mvePete O'Hanlon23-Oct-17 9:55 
GeneralRe: win6x_registry_tweak Pin
Dave Kreskowiak24-Oct-17 2:56
mveDave Kreskowiak24-Oct-17 2:56 
GeneralRe: win6x_registry_tweak Pin
Pete O'Hanlon23-Oct-17 9:49
mvePete O'Hanlon23-Oct-17 9:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.