私は、Button
コントロール、ButtonSelector
というコントロールを持つWindowsフォームを持っています。文字列変数colorBg
が現在値を格納しています。です。 Properties.Resources
には、イエローとも呼ばれる画像ファイルのエントリがあります。文字列とProperties.ResourcesからBackgroundImageを設定しますか?
ButtonSelector.BackgroundImage
をMyApp.Properties.Resources.Yellow
に設定するには、変数colorBg
の値を使用しますか?私は現在、switch-case
を使用してい
:
string colorBg = "Yellow";
switch (colorBg)
{
case "Yellow":
buttonSelector.BackgroundImage = MyApp.Properties.Resources.yellow;
break;
case "Blue":
buttonSelector.BackgroundImage = MyApp.Properties.Resources.blue;
break;
case "Green":
buttonSelector.BackgroundImage = MyApp.Properties.Resources.green;
break;
}
感謝。
の可能性の重複をそのキーを使ってリソースファイルから値を取得する方法](http://stackoverflow.com/questions/5946539/how-to-get-a-value-from-resource-file-using-its-key) – Kinetic