简体   繁体   English

更改默认图标

[英]Change default icon

I'm trying to change the application icon from default to something else.我正在尝试将应用程序图标从默认更改为其他图标。 So what I did, is I made an icon and saved it.所以我所做的是,我制作了一个图标并保存了它。 Then I went to the application tab in the property of my project and changed the icon.然后我转到项目属性中的应用程序选项卡并更改图标。 There he shows the icon like I made it, but when I run my project it shows a gray icon instead of showing my icon.他在那里显示了我制作的图标,但是当我运行我的项目时,它显示一个灰色图标而不是我的图标。

What i'm doing wrong here?我在这里做错了什么?

Run it not through Visual Studio - then the icon should look just fine.通过 Visual Studio 运行它 - 那么图标应该看起来很好。

I believe it is because when you debug, Visual Studio runs <yourapp>.vshost.exe and not your application.我相信这是因为当您调试时,Visual Studio 运行<yourapp>.vshost.exe而不是您的应用程序。 The .vshost.exe file doesn't use your icon. .vshost.exe 文件不使用您的图标。

Ultimately, what you have done is correct.最终,你所做的是正确的。

  1. Go to the Project properties转到项目属性
  2. under Application tab change the default icon to your own在应用程序选项卡下将默认图标更改为您自己的
  3. Build the project构建项目
  4. Locate the .exe file in your favorite file explorer.在您喜欢的文件资源管理器中找到 .exe 文件。

There, the icon should look fine.在那里,图标应该看起来不错。 If you run it by clicking that .exe the icon should be correct in the application as well.如果您通过单击该 .exe 来运行它,则应用程序中的图标也应该是正确的。

The Icon property for a project specifies the icon file (.ico) that will be displayed for the compiled application in Windows Explorer and in the Windows taskbar.项目的 Icon 属性指定将在 Windows 资源管理器和 Windows 任务栏中为编译的应用程序显示的图标文件 (.ico)。

The Icon property can be accessed in the Application pane of the Project Designer;可以在项目设计器的应用程序窗格中访问图标属性; it contains a list of icons that have been added to a project either as resources or as content files.它包含已作为资源或作为内容文件添加到项目中的图标列表。

To specify an application icon指定应用程序图标

  1. With a project selected in Solution Explorer, on the Project menu click Properties.在解决方案资源管理器中选择一个项目后,在“项目”菜单上单击“属性”。
  2. Select the Application pane.选择应用程序窗格。
  3. Select an icon (.ico) file from the Icon drop-down list.从图标下拉列表中选择一个图标 (.ico) 文件。

To specify an application icon and add it to your project指定应用程序图标并将其添加到您的项目中

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.在解决方案资源管理器中选择一个项目后,在“项目”菜单上,单击“属性”。
  2. Select the Application pane.选择应用程序窗格。
  3. Select Browse from the Icon drop-down list and browse to the location of the icon file that you want.从图标下拉列表中选择浏览并浏览到所需图标文件的位置。

The icon file is added to your project as a content file and can be seen on top left corner.图标文件作为内容文件添加到您的项目中,可以在左上角看到。

And if you want to show separate icons for every form you have to go to each form's properties, select icon attribute and browse for an icon you want.如果您想为每个表单显示单独的图标,您必须转到每个表单的属性,选择图标属性并浏览您想要的图标。

Here's MSDN link for the same purpose...这是出于相同目的的MSDN 链接...

Hope this helps.希望这可以帮助。

If you are using Forms you can use the icon setting in the properties pane.如果您使用的是Forms ,则可以使用属性窗格中的图标设置。 To do this select the form and scroll down in the properties pane till you see the icon setting.为此,请选择表单并在属性窗格中向下滚动,直到看到图标设置。 When you open the application it will have the icon wherever you have it in your application and in the task bar当您打开应用程序时,它会在您的应用程序和任务栏中的任何位置显示该图标

图标设置

Your application icon shows in the taskbar.您的应用程序图标显示在任务栏中。 The icon on the topleft (window) is the form-icon.左上角(窗口)的图标是表单图标。 Go to your form and fill the property "icon" with the same icon;转到您的表单并使用相同的图标填写属性“图标”; problem solved.问题解决了。 You don't need to put the icon in the outputfolder (that's just for setups).您不需要将图标放在输出文件夹中(仅用于设置)。

Go to form's properties, ICON ... Choose an icon you want.转到表单的属性,图标 ... 选择您想要的图标。

EDIT: try this编辑:试试这个

  1. Edit App.Ico to make it look like you want.编辑 App.Ico 使其看起来像您想要的。
  2. In the property pane for your form, set the Icon property to your project's App.Ico file.在窗体的属性窗格中,将 Icon 属性设置为项目的 App.Ico 文件。
  3. Rebuild solution.重建解决方案。

And read this one icons并阅读这个图标

转到项目属性 Build the project Locate the .exe file in your favorite file explorer.构建项目 在您喜欢的文件资源管理器中找到 .exe 文件。

If your designated icon shows when you run the EXE but not when you run it from Visual Studio, then, for a WPF project add the following at the top of your XAML: Icon="Images\\MyIcon.ico".如果您指定的图标在您运行 EXE 时显示,但在从 Visual Studio 运行时不显示,则对于 WPF 项目,在 XAML 顶部添加以下内容:Icon="Images\\MyIcon.ico"。 Put this just where you have the Title, and xmlns definitions.把它放在你有标题和 xmlns 定义的地方。 (Assuming you have an Images folder in your project, and that you added MyIcon.ico there). (假设您的项目中有一个 Images 文件夹,并且您在那里添加了 MyIcon.ico)。

在构建它之前,您应该将图标放在项目文件夹上

I had the same problem.我有同样的问题。 I followed the steps to change the icon but it always installed the default icon.我按照步骤更改了图标,但它始终安装了默认图标。

FIX: After I did the above, I rebuilt the solution by going to build on the Visual Studio menu bar and clicking on 'rebuild solution' and it worked!修复:完成上述操作后,我通过在 Visual Studio 菜单栏上构建并单击“重建解决方案”来重建解决方案,并且成功了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM