基于ID我想自动将Image加载到我的GUI中.为此,我希望能够从Visual Studio 2008中的Resources.resx文件中获取所有图像(使用C#).我知道如果我知道它们是什么的话我一次能得到一个:
Image myPicture = Properties.Resources.[name of file];
Run Code Online (Sandbox Code Playgroud)
然而,我正在寻找的是沿着这些方向......
foreach(Bitmap myPicture in Properties.Resources) {Do something...}
Run Code Online (Sandbox Code Playgroud)
Sha*_*men 11
只需使用Linq(tm)
ResourceManager rm = Properties.Resources.ResourceManager;
ResourceSet rs = rm.GetResourceSet(new CultureInfo("en-US"), true, true);
if (rs != null)
{
var images =
from entry in rs.Cast<DictionaryEntry>()
where entry.Value is Image
select entry.Value;
foreach (Image img in images)
{
// do your stuff
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8683 次 |
| 最近记录: |