Hi all, I have a combo box that I want to be filled with a list of folders in a specified directory. Say, C:\Temp\Folders
There are 10 folders, labeled 1-10. In the combo box it should list those folders. Thank you!
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajneesh RaiPosted Mar 5, 2013, 8:46 PM
use below code to populate combobox.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DirectoryInfo obj = new DirectoryInfo("E:\\");//you can set your directory path here
DirectoryInfo[] folders = obj.GetDirectories();
comboBox1.DataSource = folders ; // Populate combobox
}
}
}
Hope it help.
jeremiah fPosted Dec 9, 2017, 2:11 PM
justin alquistPosted Mar 5, 2013, 9:08 PM