how to just delete that windows form application icon in the left corner without replacing it with another icon?
I assume that you're using .Net WinForms.
Set the form's ShowIcon property to false.
If it is .NET (Winforms) the form should have a ShowIcon property. Set this to false.
in case you're using C++
HWND hWnd; // = WindowHandle()
::SetWindowLong(hWnd, GWL_EXSTYLE,
::GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_DLGMODALFRAME);
Related
I just upgraded some systems to Windows 10 Creators Update and I noticed that the windows forms PropertyGrid control changed its default visual style for headers and bar margins to dark gray, like so:
And as mostly happens with unexpected visual changes, users are not happy. Is there a way to revert back to the old default or maybe override the default style?
There's a bug in PropertyGrid:
The property PropertyGrid.LineColor has a DefaultValue attribute Set to SystemColors.InactiveBorder.
But the internal field lineColor is initialized with SystemColors.ControlDark.
This is bad, because the Windows Forms designer detects that the property has the same value as the DefaultValue attribute, and therefore it does not write the designer code for the PropertyGrid.LineColor property in InitializeComponent. So at runtime, the property is initialized to SystemColors.ControlDark.
As a quick hack, you can set the property after InitializeComponent:
InitializeComponent();
propertyGrid.LineColor = SystemColors.InactiveBorder;
We are reverting header color to InactiveBorder in the default windows theme in the next release of the .Net Framework, which most likely will be included in the Windows 10 Fall Creators Update. The reason this change was introduced, was that the foreground and background colors were not contrasting enough in one of the High Contrast themes, this is why we are reverting to the previously used color only in the default theme.
For your reference, internal work item number, that will be also mentioned in release notes for .Net Framework 4.7.1, is 407249.
Thank you, Tanya
This seems to be a "feature". From the .NET Framework 4.7 Release Notes:
Changed the background color of property grid lines to provide an 8:1 contrast ratio for high contrast themes.
So, I'd say, no, with Windows 10 Creators Update, there's no way to revert to the old style without recompiling (see this answer).
I complained here.
Update
I refined the PropertyGrid class like this:
sealed class LightPropertyGrid : PropertyGrid {
static readonly Color DefaultLineColor = (Color)
typeof(PropertyGrid)
.GetProperty(nameof(LineColor))
.GetCustomAttribute<DefaultValueAttribute>()
.Value;
public LightPropertyGrid() {
LineColor = DefaultLineColor;
}
}
I'm inferring the initial value for LineColor from the default value defined on the same property. Of course, you can simply assign LineColor = SystemColors.InactiveBorder.
I am facing an issue where a WinForms form is being automatically re-sized every time the designer is opened.
This only appears to happen with a certain setup, however it can easily be replicated with the following steps...
Create a new project in visual studio
The default form size is 300 x 300, but whatever you set it to make a note
Set the FormBorderStyle property to FixedSingle
Set the ShowIcon property to false
Set the ControlBox property to false
Save the changes
Close the designer
Re-open the designer and you will notice the form has shrunk by 4 pixels (both width and height)
The problem I have with this is that when it happens it does not resize any of the controls (i.e. the ones set with anchors), so this means I end up with controls that overlap the form edge and everything needs to be manually readjusted every time I open the designer which is a pain.
So the question is: Why is this happening, and what can I do to stop it happening?
I am currently using Visual Studio 2012 Professional, and John Willemse has confirmed via comments that this issue is also present in Visual Studio 2010 Professional.
I see it, this should be a bug in any VS version. It is caused by the ShowIcon property, the designer doesn't handle it correctly when you set it to False. At issue is a bit of code in the Form class that looks like this:
FormBorderStyle borderStyle = FormBorderStyle;
if (!ShowIcon &&
(borderStyle == FormBorderStyle.Sizable ||
borderStyle == FormBorderStyle.Fixed3D ||
borderStyle == FormBorderStyle.FixedSingle))
{
cp.ExStyle |= NativeMethods.WS_EX_DLGMODALFRAME;
}
In other words, when ShowIcon is False then it uses a different border style from WS_BORDER, it uses the one of a modal dialog. Which has different borders on older Windows versions, they are fatter. Not exactly sure what inspired this code, probably has something to do with Windows 98.
Problem is, the Size property is a calculated value, the Winforms designer only stores the ClientSize property. So when ShowIcon is False then it should redo this calculation, it doesn't.
You can report the bug at connect.microsoft.com but the odds that Microsoft is going to fix it are exceedingly low so it would probably be a waste of your time. There is a very simple workaround for it, instead of setting ShowIcon to False in the Properties window, do it in the constructor instead. Like this:
public Form1() {
InitializeComponent();
this.ShowIcon = false;
}
I've been working on a project in Visual Studio 2010 creating a large Windows form using C#. What's getting me is that whenever I feel I need a change to the layout of the form and open it in designer view, it will resize to a slightly smaller set of dimensions. Every time it does this I have to restore the size and relocate some of the panels as they get out of position. Would anyone know why this keeps happening? I've had to keep the designer window closed when not working in it because it will resize when I launch the project in Visual Studio, as well, if the view was left open when I last closed the project.
I am looking for that answer too. Here is something that may be similar to your question? visual studio 2005 designer moves controls and resizes Form
I had this problem in my project too.
Form Properties;
AutoScaleMode = Font
ControlBox = False
FormBorderStyle = FixedSingle
MaximizeBox = False
MinimizeBox = False
ShowIcon = False
ShowInTaskbar = False
StartPosition = CenterParent
I set my form size to 485:210. I save and close the form. I re-opened the form and size of the form changed to 481:206. I had no idea why this was happening.
First I searched around and couldn't find the solution.
AutoScaleMode set to Font in my forms.
Windows resolution is 1360 x 768.
I tried AutoScaleMode properties set to None, but the form size changed again. I changed Dpi but the result was same. I tried to use Docking for all controls in the form, but the result was same. I tried all answers which I found in stackoverflow.
I dont have any problem with my other forms. Then I realize that my other forms has ControlBox.
Then I set ControlBox properties to True. The size of the form not changed this time.
I'm using VS2010 and Crystal reports 13.
Is there any way to collapse/hide the group tree box that appears on the left hand side of my generated report? I saw a couple of proposed solutions but none seem to work for me.
Thanks in advance.
There also is a property on report viewer you can set as follows:
yourViewer.ToggleSidePanel = Constants.SidePanelKind.None;
I think this is a bit safer in case the Crystal Reports team decides to rename that button.
I finally found a solution that works, by manually finding the side panel and then hiding it:
var sidepanel = crystalReportsViewer1.FindName("btnToggleSidePanel") as ToggleButton;
if (sidepanel != null) {
crystalReportsViewer1.ViewChange += (x, y) => sidepanel.IsChecked = false;
}
adding this namespace:
using System.Windows.Controls.Primitives;
The problem was that the WPF ReportViewer is slightly diferent to the Win Forms one, some properties (such as ToolPanelView and ShowGroupTreeButton) have been removed, I tried many different things but the above was the only that did the trick.
You can change it from the designer by changing the 'ToolPanelView' to 'None' and hide the button by changing 'ShowGroupTreeButton' to 'false'. Previous versions had a method to explicitly hide the group tree but I believe it's been deprecated in the version you are using. To change the properties in code behind:
crystalreportviewer.ToolPanelView = TooPanelViewType.None;
crystalreportviewer.ShowGroupTreeButton = false;
there is a property DisplayGroupTree . and you can avoid the free space by using this code
CrystalReportViewer1.DisplayGroupTree = false;
CrystalReportViewer1.HasToggleGroupTreeButton = false;
Use the command to hide the panel.
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
I ran into the same issue as Crystal Report changes the convention. In older version of the Crystal report would hide the button and not show the panel on the left hand side.
CrystalReportViewer1.ShowGroupTreeButton = False
<Viewer:CrystalReportsViewer ToggleSidePanel="None"/>
Use the following properties in your webpage:
- ToolPanelView="None"
- HasToggleGroupTreeButton="false"
<CR:CrystalReportViewer ID="CRViewer" runat="server" HasCrystalLogo="False" ToolPanelView="None" HasToggleGroupTreeButton="false" BestFitPage="True" AutoDataBind="true" />
Group tree panel and its toggle will be hidden. It works well in my environment - ASP.Net 4.0, Crystal Report version 13.0.13
For asp.net
CrystalReportViewer1.ToolPanelView=CrystalDecisions.Web.ToolPanelViewType.None;
I have an application I'm developing which closely mirrors Windows 7's Device Stage. In Device Stage, beneath the main banner there is a ListView containing actions embodied as ListViewItems.
In my WPF application, I used WindowsFormsHost to host a WinForms ListView so that I could use SetWindowTheme() on it and apply Windows Vista/7 styling to it.
This, however, does not work and doesn't achieve the same effect it does when used in Windows Forms.
How can I achieve the Windows 7 look on a ListView in WPF? I'm not looking to create a custom style then apply it because frankly that's too much of a pain in the ass to continue using WPF for this app.
Thanks! :)
Just add the following lines:
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
public static extern int SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList);
.ctor
{
System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop();
System.Windows.Forms.Application.EnableVisualStyles();
SetWindowTheme(MyControl.Handle, "Explorer", null);
}
Apparently after digging around, the only answer does indeed appear to be creating a custom-designed control in WPF.