C#组合框项目和资源 [英] C# Combobox items and resources

查看:71
本文介绍了C#组合框项目和资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在考虑的代码,但不起作用

This is the code im thinking of but doesn''t work

private void Form1_Load(object sender, MouseEventArgs e)
    {
        comboBox1.Items.Add(Properties.Resources);
    }



加载表单时,我希望它加载我放入系统中的所有音频记录,然后

例如
我将(lol.wav)放入系统资源清单中,因此(lol)将会出现在组合框中的项目中.



When the form loads I want it to load the all audio recorces that I put in the my system recources

for example
I put (lol.wav) in my system recources, so then (lol) will appear in the combobox''s items

推荐答案

要做:涉及两个部分:
1)获取音频资源的名称
2)将它们加载到组合框中.

第二个很简单:
This is not a simple thing to do: it involves two parts:
1) Get the names of the audio resources
2) Load them into a combobox.

The second is trivial:
myComboBox.Items.Add(myAudioResourceName);



首先是乐趣所在!
您将获得程序集中所有资源的列表:



The first is where the fun is!
You get to get a list of all resources in your assembly:

string[] all = System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceNames();


然后,您需要确定资源是否为音频文件-它会以以下形式返回名称的列表:


Then, you need to decide if the resource is an audio file or not - it will return a list a of name in the form:

MyProject.MyForm.resources
MyProject.Properties.Resources.resources
MyProject.Resources.mySample.mp3

您将不得不从中挑选音频文件!

You will have to pick the audio files out of that!


这篇关于C#组合框项目和资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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