using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace POC1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] files = Directory.GetFiles(@"C:\\");
foreach (string file in files)
{
comboBox1.Items.AddRange(files);
}
}
}
}
我使用下面的代碼,但我無法讓我的組合框填充任何數據。我很確定我使用了我搜索過的例子。用目錄文件填充組合框
你能用'comboBox1.DataSource = files; comboBox1.DataBind();'? FBD似乎也未被使用。 – ibiza
使用斷點,'文件'在調用GetFiles之後是否有任何條目?此外for循環看起來有問題。 '文件中的文件'...'AddRange(fileS)' – KDecker
@ibiza我現在刪除它。我的錯。 – Intelwalk