Sri*_*ava 79 c# visual-studio winforms
I need to change the icon in the application I am working on. But simply browsing for other icons from the project property tab -> Application -> Icon, it is not getting the icons stored on the desktop..
What is the right way of doing it?
Jav*_*ram 81
您在桌面上看到的图标不是图标文件.它们是可执行文件.exe或任何应用程序.lnk的快捷方式.所以只能设置具有.ico扩展名的图标.
转到项目菜单 - > Your_Project_Name属性 - >应用程序选项卡 - >资源 - >图标
浏览你的Icon,记住它必须有.ico扩展名
您可以在Visual Studio中创建图标
转到项目菜单 - >添加新项目 - >图标文件
Lor*_*uer 18
任务栏和窗口标题中显示的图标是主窗体的图标.通过更改其Icon,您还可以设置任务栏中显示的图标,当您已包含在*.resx中时:
System.ComponentModel.ComponentResourceManager resources =
new System.ComponentModel.ComponentResourceManager(typeof(MyForm));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("statusnormal.Icon")));
Run Code Online (Sandbox Code Playgroud)
或者,直接从您的资源中读取:
this.Icon = new Icon("Resources/statusnormal.ico");
Run Code Online (Sandbox Code Playgroud)
如果你不能立即找到它的代码Form,搜索整个项目(CTRL+SHIFT+F)以显示所显示的Window-Title(假设文本是静态的)
小智 16
添加您的图标作为资源(项目> yourprojectname 属性> 资源> 从下拉列表中选择“图标> 添加资源(如果您已经拥有.ico,则从下拉列表中选择添加现有文件)
然后:
this.Icon = Properties.Resources.youriconname;
小智 6
一旦图标在 Visual Studio 中采用 .ICO 格式,我就使用
//This uses the file u give it to make an icon.
Icon icon = Icon.ExtractAssociatedIcon(String);//pulls icon from .ico and makes it then icon object.
//Assign icon to the icon property of the form
this.Icon = icon;
Run Code Online (Sandbox Code Playgroud)
所以简而言之
Icon icon = Icon.ExtractAssociatedIcon("FILE/Path");
this.Icon = icon;
Run Code Online (Sandbox Code Playgroud)
每次都有效。
将以下行放入表单的构造函数中:
Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
Run Code Online (Sandbox Code Playgroud)
我将 .ico 文件添加到我的项目中,将 Build Action 设置为Embedded Resource。我在项目设置中指定了该文件的路径作为项目的图标,然后我在表单的构造函数中使用了下面的代码来共享它。这样,我不需要在任何地方使用图标副本维护资源文件。更新它所需要做的就是替换文件。
var exe = System.Reflection.Assembly.GetExecutingAssembly();
var iconStream = exe.GetManifestResourceStream("Namespace.IconName.ico");
if (iconStream != null) Icon = new Icon(iconStream);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
166028 次 |
| 最近记录: |