导航:首页 > 文件处理 > combox导入所有文件夹名称

combox导入所有文件夹名称

发布时间:2022-05-10 06:04:57

‘壹’ C#,winform中下拉框combox的内容想读取桌面的文件夹名称

添加一个按钮,将这里这个函数的代码放在按钮单击事件的处理函数中。同时取消对CB的SelectedIndexChanged事件的响应。下拉框是空的,是因为1、你不能在处理CB的SelectedIndexChanged事件的函数中改变CB的Items集合的值。2、目录C:\Users\Desktop\test\中可能没有文件。

‘贰’ C# 从数据库添加数据到combox

可以用datatable保存你取得的记录,假设有comboBoxDept
datatable dt = Query();
for(int i=0;i<dt.rows.count;i++)
{
comboBoxDept.items.add(dt.rows[i]["部门名称"];
}
其中dt就是datatable类型
查询语句参照如下代码:
public DataTable Query()
{
strCommand = "SELECT 部门名称 FROM 学生会管理";
cmd.CommandText = strCommand; // cmd是sqlCommand对象
SqlDataAdapter da = new SqlDataAdapter(strCommand, conn);
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
dt = ds.Tables[0];
return dt;
}

‘叁’ mfc将根目录下的txt文件名读取并依次加入combobox中怎么搞

是只需要读根目录下的文件,不包括子文件夹文件吗?
如果是的话,我这里有一点之前写的代码给你给你参考下:
struct FileMsg_struct
{
CString File_name;
CString File_path;
CString File_lawritetime;
byte bResult;
};
struct Dir_struct
{
vector<Dir_struct*> Subdric;
CString subdric_name;
vector<FileMsg_struct*> File;
byte bsucdir;
};

CfindfileDlg::Dir_struct* CfindfileDlg::fun(CString strPath)
{
CFileFind Findwork;
CString path = strPath;
path = path + "\\*.*";

CfindfileDlg::Dir_struct dir_init;
dir_init.bsucdir = 0;
dir_init.subdric_name = "Rootdir";
CfindfileDlg::Dir_struct* dir = new Dir_struct(dir_init);//开辟内存空间
Dir_struct* sumdir;

BOOL bFindwork = Findwork.FindFile(path);
while(bFindwork)
{
bFindwork = Findwork.FindNextFile();

if (Findwork.IsDots()) //IsDots判断是否为点--这个要说明一下,用过Dos的话,就应该知道,每个目录下都有缺省的两个目录,名称分别为 '. '和 '.. ',分别代表上一层目录和本层目录。
{
continue;
}
if (Findwork.IsDirectory())
{
CString path1 = Findwork.GetFilePath();
// m_list.AddString(Findwork.GetFileName());
sumdir = fun(path1);
sumdir->subdric_name = Findwork.GetFileName();
dir->Subdric.push_back(sumdir);
}
else
{
CfindfileDlg::FileMsg_struct FileMsg_init;
FileMsg_init.File_lawritetime="";
FileMsg_init.File_name="";
FileMsg_init.File_path="";
FileMsg_init.bResult=0;
CfindfileDlg::FileMsg_struct* FileMsg = new FileMsg_struct(FileMsg_init);
FileMsg->File_name.Format("%s",Findwork.GetFileName());

FILETIME ft;
Findwork.GetLastWriteTime(&ft);
// TRACE("%d %d\r\n",ft.dwHighDateTime,ft.dwLowDateTime);
CTime ct(ft);
FileMsg->File_lawritetime.Format("%d年%d月%d日-%d:%d:%d",ct.GetYear(),ct.GetMonth(),ct.GetDay(),ct.GetHour(),ct.GetMinute(),ct.GetSecond());

// TRACE("filename=%s lasttime=%s\r\n",FileMsg->File_name,FileMsg->File_lawritetime);

dir->File.push_back(FileMsg);
}

}
Findwork.Close();
return dir;
}

‘肆’ c#中怎么像COMBOX中添加值和名称。最好举个例子

需知comboBox里的项都是对象实例
新建一个类
/// <summary>
/// 选择项类,用于ComboBox或者ListBox添加项
/// </summary>
public class ListItem:System.Object
{
private string id = string.Empty;

public string Id
{
get { return id; }
set { id = value; }
}
private string name = string.Empty;

public string Name
{
get { return name; }
set { name = value; }
}

public ListItem(string sid, string sname)
{
this.Id = sid;
this.Name = sname;
}

public override string ToString()
{
return this.Name;
}
}

static void Main()
{
List<ListItem> items = new List<ListItem>();//添加项的集合
ListItem item = new ListItem("显示文字内容1","value值1");
ListItem item = new ListItem("显示文字内容2","value值2");
ListItem item = new ListItem("显示文字内容3","value值3");
items.Add(item);

comboBoxGroup.DisplayMember = "Name";
comboBoxGroup.ValueMember = "Id";
comboBoxGroup.DataSource = items;
this.comboBoxGroup.SelectedIndex = 0;
//下拉框事件
comboBoxGroup.SelectedIndexChanged += new EventHandler(comboBoxGroup_SelectedIndexChanged);
return 0;
}

搞定~
}

‘伍’ 如何将文件夹中所有子文件夹的名字导入到excel

1、在D盘新建一个文件夹D:生成文件,并将要生成列表的文件全部放入该文件夹中。

2:下载我给你的附件,运行,会产生一个“生成文件.txt”。

3、用excel打开这个文本文件。

也可以参考,http://jingyan..com/article/54b6b9c0d2cf612d583b4702.html

如果不会可以私信找我。

‘陆’ excel批量导入文件夹名称

Excel表格当中选插入文件。
插入文件内容当中,点击需要插入的文本表格,进入文件夹,全部选定点击确定。
就可以批量导入文件名称。

‘柒’ EXCEL VBA 关于Combox:如何将一张表内的一列数据导入到它的列表中

第一个问题,在Auto_Open或ThisWorkbook_Open事件中添加代码将这张表中的数据使用For Next循环加入到复合框中。
第二个问题,在ComboBox1的Change事件中添加ComboBox2的内容。
没有示例文件,不太好说。你可以到http://club.ExcelHome.net或http://www.ExcelJY.com上发帖去问问。

‘捌’ 在VB中,如何将一个文件夹下的所有文件的文件名挨着赋值给combobox的下拉列表中

Private Sub Command1_Click()
stri = Dir("c:\windows\*.*")
Do
Combo1.AddItem stri
stri = Dir
Loop Until stri = ""
End Sub

‘玖’ C# Winform里面怎么把一个文件夹下面的文件名称读取出来到ComBox的下拉列表框、有很多文件名的

string strUserDirPath="你的目录路径";
if (Directory.Exists(strUserDirPath) == true)
{
string[] strArrFiles = Directory.GetFiles(strUserDirPath);
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("user", typeof(string));
dt.Columns.Add(dc);
foreach (string s in strArrFiles)
{
DataRow dr = dt.NewRow();
dr[0] = Path.GetFileName(s);
dt.Rows.Add(dr);
}
return dt;
}
this.cmbox_UserInfo.ValueMember = "user";
this.cmbox_UserInfo.DisplayMember = "user";
this.cmbox_UserInfo.DataSource = dt;

‘拾’ 如何批量将文件导入对应文件名的文件夹

右击 导入 指定文件夹
要不就是复制 粘贴

阅读全文

与combox导入所有文件夹名称相关的资料

热点内容
卡尔曼滤波算法书籍 浏览:768
安卓手机怎么用爱思助手传文件进苹果手机上 浏览:843
安卓怎么下载60秒生存 浏览:802
外向式文件夹 浏览:235
dospdf 浏览:430
怎么修改腾讯云服务器ip 浏览:387
pdftoeps 浏览:492
为什么鸿蒙那么像安卓 浏览:735
安卓手机怎么拍自媒体视频 浏览:185
单片机各个中断的初始化 浏览:723
python怎么集合元素 浏览:480
python逐条解读 浏览:832
基于单片机的湿度控制 浏览:498
ios如何使用安卓的帐号 浏览:882
程序员公园采访 浏览:811
程序员实战教程要多长时间 浏览:974
企业数据加密技巧 浏览:134
租云服务器开发 浏览:813
程序员告白妈妈不同意 浏览:335
攻城掠地怎么查看服务器 浏览:600