最近在帮客户把VB的系统转到C#的版本 记录一下在C#如何使用VB的FileListBox控件 最近在帮客户把VB的系统转到C#的版本 记录一下在C#如何使用VB的FileListBox控件 首先在VS工具箱加入VB的FileL
最近在帮客户把VB的系统转到C#的版本
记录一下在C#如何使用VB的FileListBox控件
最近在帮客户把VB的系统转到C#的版本
记录一下在C#如何使用VB的FileListBox控件
首先在VS工具箱加入VB的FileListBox控件,如下图所示
再拉FileListBox到表单里
这个控件主要功能是可以设定一个目录的路径,然后显示此目录的所有文件在控件里
C#程序:
using System;
using System.Windows.Forms;
namespace WinFormCSharp
{
public partial class FrmFileListBox : Form
{
public FrmFileListBox()
{
InitializeComponent();
}
private void FrmFileListBox_Load(object sender, EventArgs e)
{
fileListBox1.Path = @"c:puma";//指定路径
}
private void btnRefresh_Click(object sender, EventArgs e)
{
fileListBox1.Refresh();//更新FileListBox的项目
}
private void btnShowItem_Click(object sender, EventArgs e)
{
foreach (string item in fileListBox1.Items)//读出指定路径下的所有文件
{
MessageBox.Show(item);
}
}
}
}
执行结果:
原文:大专栏 [C#][WinForm]在C#使用VB的FileListBox控件
