Combobox - 相对和绝对目录 [英] Combobox - Relative and Absolute directory

查看:69
本文介绍了Combobox - 相对和绝对目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends,



我的组合框需要相对目录和亲戚。看......



string myDir = @c:\;

Directory.GetDirectories(myDir);



cboDocumento.SelectedItem = a.GetRelativePath();

cboDocumento.SelectedValue = a.GetAbsolutePath();

cboDocumento.DataSource = a;



怎么样?

Hello Friends,

I need relative directory and relative on my combobox. Look...

string myDir = @"c:\";
Directory.GetDirectories(myDir);

cboDocumento.SelectedItem = a.GetRelativePath();
cboDocumento.SelectedValue = a.GetAbsolutePath();
cboDocumento.DataSource = a;

how to ?

推荐答案

您通常需要将更多信息放到列表框,组合框等中。不仅仅是在这种情况下。此外,列表项目中显示为字符串的数据不应被视为良好的输入数据。



您应该使用简单的事实:项目没有成为字符串。在你的情况下,他们不应该。您需要开发用于表示列表元素的综合数据类型。怎么样?请查看我过去的答案:

combobox.selectedvalue显示{}在winform中 [ ^ ],

Windows窗体列表框选择 [ ^ ]。



另请注意,使用表示数据而非数据本身的字符串是目前许多初学者的一大谬误。尽量避免它。



-SA
You usually need to put more information to list boxes, combo boxes, etc. Not only in this case. Moreover, the data shown as strings presented in the list items should not be considered as good input data.

You should use the simple fact: the items don't have to be strings. In your case, they should not be. You need to develop a comprehensive data type used to represent the elements of the list. How? Please see my past answers:
combobox.selectedvalue shows {} in winform[^],
Windows Form ListBox Selections[^].

Also note that working with strings representing data instead of data itself is a big fallacy of many beginners these days. Try to avoid it.

—SA


这篇关于Combobox - 相对和绝对目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆