Use listbox items in function C#
NickName:I love Code Ask DateTime:2017-07-22T02:24:56

Use listbox items in function C#

I have listed all directories in a folder in a listbox.

    private void Form1_Load_1(object sender, EventArgs e)
    {
          listBox3.Items.Clear();
          string[] dirs = Directory.GetDirectories("C:\\Users\\foo\\Desktop\\test");

          foreach (string dir in dirs)
          {
            listBox3.Items.Add(dir);
          }
    }

How can I list the subdirectories as well? As if it were the command "tree" of the windows command prompt. thanks

Copyright Notice:Content Author:「I love Code」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45244389/use-listbox-items-in-function-c-sharp

More about “Use listbox items in function C#” related questions

Use Items from listbox in function C#

I have listed all the directories in a listbox. private void Form1_Load_1(object sender, EventArgs e) { listBox3.Items.Clear(); string[] dirs = Directory.GetDirectories("C:\\Users\\foo\\

Show Detail

Use listbox items in function C#

I have listed all directories in a folder in a listbox. private void Form1_Load_1(object sender, EventArgs e) { listBox3.Items.Clear(); string[] dirs = Directory.

Show Detail

Listbox items not selectable

In silverlight, I'm creating a listbox at runtime. The listbox displays on the page okay but the items aren't selectable - I don't understand why? Am I doing something wrong? Here's my code: C# p...

Show Detail

C# Listbox selecting items

my For statement is not highlighting/selecting items from the listbox am missing something? if (listId.Items.Count != 0 && listCell.Items.Count != 0) { for (int a = 0; a <

Show Detail

Add items to listbox in C# with thread

I want to add some items to listbox with a thread or backgroundworker in C#. But when I call addlist function in a loop my program is not responding for a while. How can I fix that? Here is my cod...

Show Detail

Moving items in a listbox in c#

I am adding file names from a directory in a list box which I am able to add successfully.I then should be able to arrange the files in the list box by selecting a particular item & then movin...

Show Detail

Error when use listbox to display data in function

I want to display data in listbox , but I can not use listBox1 in function , I declare it in program but can not use in function , how can I use listBox1 in function to display data void threeta...

Show Detail

adding multiple listbox items into one listbox

I'm using vb.net form. I have 8 listboxes (listbox1 , listbox2,listbox3..) each one contains many items and another empty listbox (listbox10). I'm trying to add first listboxes items into the lis...

Show Detail

Deleting listbox items in C# winform

I can't figure out how to correctly remove items from winform listbox in c#. The listbox is populated with some string from FileSystemWatcher which basically puts in the listbox which files are mo...

Show Detail

Getting the indexes of selected items in a listbox in C#

I'm filling a listbox with some values from a table like this: private void LoadFunctions() { using (SqlConnection con = new SqlConnection(str2)) { try ...

Show Detail