0

C# Windows フォーム アプリケーションの ToolStripStatusLabel 項目にアイコンを設定できるようにする必要があります。アイテムには画像とテキストが表示されます。私はそのようなアイテムでアイコンを使用できると思っていましたが、間違っています。既存の Icon オブジェクトから Image オブジェクトを作成する最良の方法は何ですか?

意図したコードは次のようになります。

Image image = new Image(); // Get this image somehow from a pre-existing Icon object
serverInfoToolStripStatusLabel.Text = "Connected to server X";
serverInfoToolStripStatusLabel.Image = image;

(注意: serverInfoToolStripStatusLabel は System.Windows.Forms.ToolStripStatusLabel として宣言されています) について。

4

2 に答える 2

0

Icon には ToBitmap メソッドがあり、これは Image である Bitmap を提供します。

于 2010-03-01T11:06:15.163 に答える