Wrong (Default?) Icon shown in Taskbar - c#

I have a Form which I show with ShowDialog. I explicitely set the icon for the form with:
using (frmActivation myActivationView = new frmActivation())
{
myActivationView.ShowInTaskbar = true;
myActivationView.Icon = Properties.Resources.icon;
myActivationView.ShowDialog();
}
And I also set it in the project properties in the application tab as mentionend here:
Even though I have set ShowInTaskbar explicitely to true, it will show me the wrong icon.
I'm out of ideas what else could be the reason that it won't show the set icon?

It's not enough to set ShowInTaskbar. You must also make sure that the property ShowIcon of the form is set to true.
Based on the screenshot of your form and the fact, I can't see an icon in the upper left corner, I guess you haven't set it yet.
From the MSDN: Form.ShowIcon Property
The ShowIcon property contains a Boolean value that indicates whether the form's Icon is displayed in the caption bar of the form. If the ControlBox property is false, both the icon and control box will be suppressed.
If ShowIcon is false when the primary form is shown, a generic icon will be displayed in the taskbar button for the application.

Related

ShowInTaskbar not working reliably in WPF

I have a modal window in WPF and for this window ShowInTaskbar is set to true but application icon is not showing in taskbar every time for this model window. Sometimes the icon shows up in taskbar and sometimes it does not. But the requirement is application icon should always be visible in the taskbar when this modal window (using ShowDialog) is launched.
window Style is set as : ThreeDBorderWindow
Code to show modal window is :
winIHelper = new WindowInteropHelper(_shell);
_shell.SizeToContent = SizeToContent.WidthAndHeight;
winIHelper.Owner = parentHandle;
_shell.ShowInTaskbar = true;
_shell.Activate();
_shell.ShowDialog();
I had a similar case where ShowInTaskbar was not working correctly when a different window (Splash screen in my case) was shown without setting any Owner.
So, settings the Owner property of the Other window - solved my case.

Howto enable the expand button in a devexpress Treelist

I have a winforms form with a DevExpress TreeList on it.
The Treelist is drawn as expected.
But the indicator known as "expand button" is missing.
According to the DevExpress Manual the button could be disabled with
OptionsView.ShowButtons = false;
However the TreeList.OptionView.ShowButton value is true.
(It is true during debugging, also no change if I explicitly set it to false and then again to true during initialization)
Which settings can be done so that the "expand button" disappears other then ShowButtons = false?
Try to make the root visible :
treeList1.OptionsView.ShowRoot = true;

Disable resizing of a Windows Forms form

How do I turn off the user's ability to resize a Windows Forms form?
I'm having it resize itself on a click.
Take a look at the FormBorderStyle property
form1.FormBorderStyle = FormBorderStyle.FixedSingle;
You may also want to remove the minimize and maximize buttons:
form1.MaximizeBox = false;
form1.MinimizeBox = false;
First, select the form.
Then, go to the properties menu.
And change the property "FormBorderStyle" from sizable to Fixed3D or FixedSingle.
More precisely, add the code below to the private void InitializeComponent() method of the Form class:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Explanation
By default, FormBorderStyle property has the sizable value FormBorderStyle.Sizable assigned. Which enables form to be resized.
There are 7 kinds of FormBorderStyle property values available to use.
None
FixedSingle
Fixed3D
FixedDialog
Sizable
FixedToolWindow
SizableToolWindow
Depending upon the kind of form, we can assign the appropriate value accordingly.
Assuming your form name is form1.
Choose any one from below to make it as Fixed
FixedSingle, Fixed3D, FixedDialog makes the form non-resizeable, assigning None will also work but won't make sense without a control box in case.
Code
Code snippets below, use any one of them
FixedSingle
form1.FormBorderStyle = FormBorderStyle.FixedSingle;
Fixed3D
form1.FormBorderStyle = FormBorderStyle.Fixed3D;
FixedDialog
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
None [Optional] Note: There'd no control box
form1.FormBorderStyle = FormBorderStyle.None;
Or, Graphically
We can apply it graphically like this.
Make sure you've selected the form which you want to make it fixed size. then you'll see a property named FormBorderStyle property there in Properties window.
Another way is to change properties "AutoSize" (set to True) and "AutosizeMode" (set to GrowAndShrink).
This has the effect of the form autosizing to the elements on it and never allowing the user to change its size.
None of these answers worked for me, perhaps because my window had a status bar. To fix I did this:
StatusStripObject.SizingGrip = False
The same works for a StatusBar object, e.g.:
StatusBarObject.SizingGrip = False
There is far more efficient answer: just put the following instructions in the Form_Load:
this.MinimumSize = new Size(Width, Height);
this.MaximumSize = this.MinimumSize;

Show hidden window

I'm creating child console application using Process.Start method. Process is created with WindowStyle set to ProcessWindowStyle.Hidden. But then I need to SendInput to this window and try to show it using ShowWindow method. But ShowWindows has no effect.
You need to change also the property of process style form hidden to normal.
The methods Show() set the property is equal to setting the property Visible to true (the Hide() sets it to false).
From the description of ProcessWindowStyle.Hidden:
The hidden window style. A window can
be either visible or hidden. The
system displays a hidden window by not
drawing it. If a window is hidden, it
is effectively disabled. A hidden
window can process messages from the
system or from other windows, but it
cannot process input from the user or
display output. Frequently, an
application may keep a new window
hidden while it customizes the
window's appearance, and then make the
window style Normal.
So in your case, you will have to set the WindowStyle property of Process.StartInfo to ProcessWindowStyle.Normal.

C# 2005: Remove icon from the form's title bar

A client has asked me to remove the icon from the form's title bar. As they don't want to display any icon. But this me guessing as when I click on the icon property you have to browse to some icon.
Set ShowIcon Property of the form to False to see if that's what your client wants.
There are two ways.
First is to create an empty Icon file and then Select Form -> Right Click -> Goto Properties -> Goto Icon -> Select your file.
The other approach is to set FormBorderStyle of the form to FormBorderStyle.SizableToolWindow or FormBorderStyle.FixedToolWind
And one more way is to set ShowIcon property to be false.
Set
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
You can set ControlBox = false. However, that will remove not only the icon but also maximize and minimize buttons from the title bar.
There appears to be an updated process. Following the steps in the selected answer doesn't direct me to an option to upload an icon. That option can be found on Microsoft's site: https://support.office.com/en-us/article/add-a-custom-title-or-icon-to-a-database-0e43e135-dd0d-4451-84ea-4f547e14480e
You can also try this:
this.Icon = null;
Icon > False
This COULD be a good approach, but these are good too:
this.Icon = null;
//Or
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
//Or
Select Your Form -> Right-Click -> Properties -> Icon -> Select file
That's all I have for this, I hope this helps you.

Categories