Why does my icon not appear in the title bar? - c#

I have assigned an icon to my application from the Properties window in Solution Explorer in Visual Studio; the application's icon changed successfully but the title bar is still showing the default icon:
I've rebuilt my application but it still displays the default icon. What am I doing wrong?

Because forms have a different icaon configuration than the application. Set the icon on the form, not ONLY on the application.

There is another reason why the icon might not show.
If the ControlBox property of the Form is set to False the icon will not show.
(Sounds like an undesired side effect)

I know that it is a very old issue but I can add the following comment :
Pay attention to the 'FormBorderStyle' property.
If 'FixedToolWindow' or 'SizableToolWindow' are selected, your icon will not appear, even if you specified an icon in the 'Icon' property.
I encountered the same issue.
Good luck.

The form itself has an Icon property you need to set as well.

If you using winform you need to set the icon property of your main form

You didn't mention if you are using winforms or wpf - wpf will place the icon on all windows/forms unless overridden.
Winforms requires individually set icons.

Related

Changing Form's Icon in Visual Studio 2012 C#

I am trying to change the icon of the form (top left) and any other place I see little squares default icon.
I have tried:
Clicking the form, go to "Window Style" and changing the Icon to the .ico file I have on my computer - this shows as if it actually changes - but whenever I debug or publish - it is still the original default Icon.
Going to Project's properties- Resources - adding the Icon as Resource - back to Application under Properties - change "Icon and Manifest" to the resourced Icon. It shows the new Icon next to the browse button - but nothing changes in the actual program.
Note at first the Background Image I had selected for the form wasn't applying either - I would change it via the form - Properties - Appearance - BackgroundImage - Select from computer. Would show as changed but as soon as I would debug or publish or would not be there.
-Added it to my resources and then chose it from the BackgroundImage browse - chose it from project resources and then it worked.
Found a solution:
With the idea that my Background image wasn't working until I had it in the Resources. I went to the Form1_load event and added the following code:
System.Drawing.Icon ico = Properties.Resources.Untitled;
this.Icon = ico;
As "Properties.Resources.Untitled" being my icon that I added to my Resources.
And now seems to be workings as wanted.
You need to change the icon on every form as well using the Icon property of the Form.

How to Show the Form's Own Icon on a Floating Window using DockPanel and its Extender?

With the Weifen Luo DockPanel component, one can add to their .net project the ability to dock forms within other forms. The component is very well done.
Now, I see from this page at the project forum at github (where this component is now hosted), that it is possible, through the use of this dock.extender to allow the floating windows to have a normal winform look, that is, sizeable with regular Windows title bar, maximize box, minimize box, etc (see here, too). This also allows for the form's icon to show.
My problem is, and hence my question, is that the icon I assign in the form's properties will show in the designer, but one it runs in debug as a float-panel, a generic form icons appears in its place.
Now, I tried assigning the icon through code (both in the form's own code, and in the main application code too, where the form is called) rather than through properties, and that didn't work either.
So how do I get my own custom icon to show as the form's icon when the form is floated, and the extender is used? I am using the main docking panel in DockingWindow mode.
[EDIT]
I think this is a hard question! It's been 2 days and I've not gotten any answers!
This requires a change to the the FloatWindow class itself to set and update the Icon property internally as the content changes.
I have just checked the change in and it will be included in the 2.7 release of the library.
https://github.com/dockpanelsuite/dockpanelsuite/issues/35

how to: make a panel resize with its form; and attach a console for output

how to make the Panel widget change it's size on Form1_SizeChanged
how to attach a console window in order to see console.writeline messages
Take a look at the Anchor and Dock properties on the panel. These let the panel change its size along with the form; you won't need to write any code.
It's a little tricky to attach a console to a running app. If you're just interested in seeing debug messages, look at the Visual Studio output window, or call Debug.WriteLine instead.
To resize a control when the parent control size changed you can use the Control.Anchor property.
To get a console window for a WinForms application just go to Project Properties and change Output type in the Application tab from Windows Application to Console Application.
Easiest way to get your Panel to resize is to Anchor or Dock it into the form. Play with the properties pane a bit and you should see how it works.
Use Anchor or Dock properties. To see the console window in Visual Studio go to the menu View and there you should check displaying "Output".

How to display different icons in form title and in ALT-TAB window?

Is there a way to have this behaviour with WinForms?
The icon for the form is the Form.Icon property, The icon for the application (and Alt-Tab) is set in Visual Studio under Properties, Application, Resources.
Simply set the Form.Icon property!

Adding help icon to WinForms form titlebar

Some Windows native applications have a question mark icon on the title bar. It's usually at the right edge, just near the close button. How can I do this in a C# WinForms application? I'd like a solution that works in Windows XP onward.
Set the form's HelpButton property to True. You also need to have the MaximizeButton and MinimizeButton properties set to False.

Categories

Resources