Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to figure out how to change the icon on a form after a button click.

Example: I can change the Form text by using

VB
Form3.Text = ("Form Title Here")


Yeah pretty simple.

But the issue I'm trying to figure out is how to change the forms Icon the same way.

What I have tried:

VB
Form3.Icon = ("iconname.ico")
Obviously isn't the correct way, I have searched but the only thing I can find is changing the icon via Properties. Which isn't what I'm looking for. I'm making this harder than it should be.
Posted
Updated 9-Sep-22 1:47am
Comments
Com Com 2023 21-Apr-23 13:09pm    
how to make button in c++

Try:
C#
Icon = new Icon(@"D:\Test Data\MyICon.ico");
The this.Icon will pick up the Form instance from the class in a non-static Form Event handler.
 
Share this answer
 
I'll accept this solution because it pointed me in the right direction, just I'm using VB as opposed to C#, But I was just missing the one little piece.

It ended up being
VB
Form3.Icon = New Icon("IconName.ico")


Thanks!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900