Convert any image file PNG, JPG , BMP to windows form application form icon. From resources select any image and convert to icon. In this snippet example combobox dropdown select index change event convert bitmap to form icon.
Example Source Snippets - FormDynamicIChangeIcon.zip
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace FormDynamicIChangeIcon { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Bitmap targetBmp; IntPtr Hicon = new IntPtr(); Icon FrmIcon; if (comboBox1.Text == "green") { targetBmp = global::FormDynamicIChangeIcon.Properties.Resources.green; Hicon = targetBmp.GetHicon();//Returns handle to an icon with the same image as the System.Drawing.Bitmap. FrmIcon = Icon.FromHandle(Hicon); this.Icon = FrmIcon; } else if (comboBox1.Text == "red") { targetBmp = global::FormDynamicIChangeIcon.Properties.Resources.red; Hicon = targetBmp.GetHicon(); FrmIcon = Icon.FromHandle(Hicon); this.Icon = FrmIcon; } else { targetBmp = global::FormDynamicIChangeIcon.Properties.Resources.yellow; Hicon = targetBmp.GetHicon(); FrmIcon = Icon.FromHandle(Hicon); this.Icon = FrmIcon; } } } }
smartsnipps.ecomparefiles.com © 2021, All Rights Reserved | Disclaimer: smartsnipps.eCompareFiles.com is free to use any code snippets without guarantee