0
當我想這樣選擇圖像,項目資源爲空:如何將資源添加到SharpDevelop中的C#項目?
當我想這樣選擇圖像,項目資源爲空:如何將資源添加到SharpDevelop中的C#項目?
解決方案,我用.resx文件:
假設我們添加「Image.png」。要訪問這些文件,使用此代碼:
using System.Reflection;
using System.Resources;
ResourceManager resources = new ResourceManager("Namespace.ResourceFile", Assembly.GetExecutingAssembly());
Bitmap bitmap = (Bitmap) resources.GetObject("Image"); //image without extension
myButton.BackgroundImage = bitmap;
命名空間是應用程序的根命名空間,在的resourcefile .resx文件的名稱(不帶擴展名的.resx)。如果.resx文件位於項目的子文件夾內,請使用「Namespace.SubfolderName.ResourceFile」。 確保圖像符合Control.Size,屬性BackgroungImage不會調整圖像大小。 resx文件就像一個文件夾,它將會保留你的資源。
只是要確定:你讀過https://github.com/icsharpcode/SharpDevelop/wiki/Using-Resources –
@ C.Evenhuis謝謝。 – tomyforever