private void BtnBrowse_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { Title = "更改图标", Filter = "图标文件|*.ico;*.exe;*.dll|程序|*.exe|库|*.dll|图标|*.ico|所有文件|*.*" }; if (ofd.ShowDialog() == DialogResult.OK) { string fileName = ofd.FileName; txtPath.Text = fileName; pnlICO.Controls.Clear(); TileIcon tileIcon = new TileIcon(); tileIcon.LoadIcon(fileName); tileIcon.ShowIcon(pnlICO); } }
public FormReplaceIcon(string iconPath) { this.InitializeComponent(); this.IconPath = null; this.IconIndex = -1; this.AcceptButton = btnOK; this.CancelButton = btnCancel; if (iconPath != null) { txtPath.Text = iconPath; TileIcon tileIcon = new TileIcon(); tileIcon.LoadIcon(iconPath); tileIcon.ShowIcon(pnlICO); } btnBrowse.Click += BtnBrowse_Click; btnOK.Click += BtnOK_Click; btnCancel.Click += BtnCancel_Click; }