Here is the picture that shows the problem. Take a look at the bottom right corner.
这是显示问题的图片。看看右下角。
Anyone knows how to get rid of it?
谁知道如何摆脱它?
Setting LayoutStyle
to VerticalStackWithOverflow
fixes it but also centers the items horizontally which I don't want.
将LayoutStyle设置为VerticalStackWithOverflow会修复它,但也会将项目水平居中,这是我不想要的。
I just want a vertical stack like in the pic, but without that black line in the bottom right corner.
我只想要像照片中的垂直堆栈,但右下角没有黑色线条。
3 个解决方案
#1
12
In the properties bar, set "RenderMode" to "System" or use
在属性栏中,将“RenderMode”设置为“System”或使用
.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
Doing this will change the .BackColor to "Control" but you can change that after if you want.
这样做会将.BackColor更改为“Control”,但您可以根据需要更改。
#2
13
Sorry for being late to the party, but the accepted answer didn't work for my needs. The following solution is what I came up with:
很抱歉迟到了,但接受的答案对我的需求不起作用。我想出了以下解决方案:
Getting rid of the black line
1) Create a custom renderer:
1)创建自定义渲染器:
class CustomToolStripProfessionalRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
// Don't draw a border
}
}
2) Use the custom renderer:
2)使用自定义渲染器:
toolStrip1.Renderer = new CustomToolStripProfessionalRenderer();
Getting rid of the background
The above solution satisfies the need of the original question, but I didn't like the gradient background on the ToolStrip either. I wanted the ToolStrip to be an "invisible" container:
上面的解决方案满足了原始问题的需要,但我也不喜欢ToolStrip上的渐变背景。我希望ToolStrip成为一个“隐形”容器:
1) Create a custom color table:
1)创建自定义颜色表:
class CustomProfessionalColorTable : ProfessionalColorTable
{
public override Color ToolStripGradientBegin
{
get { return SystemColors.Control; }
}
public override Color ToolStripGradientMiddle
{
get { return SystemColors.Control; }
}
public override Color ToolStripGradientEnd
{
get { return SystemColors.Control; }
}
}
2) Use the custom color table:
2)使用自定义颜色表:
class CustomToolStripProfessionalRenderer : ToolStripProfessionalRenderer
{
public CustomToolStripProfessionalRenderer()
: base(new CustomProfessionalColorTable())
{
}
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
// Don't draw a border
}
}
#3
3
I think your best shot would be to set the RenderMode
to System
in the properties and leave the layout properties to HorizontalStackWithOverflow
. But that is if you don't mind changing the tooltip paint style.
我认为你最好的方法是在属性中将RenderMode设置为System,并将布局属性保留为HorizontalStackWithOverflow。但那就是你不介意改变工具提示的绘画风格。
#1
12
In the properties bar, set "RenderMode" to "System" or use
在属性栏中,将“RenderMode”设置为“System”或使用
.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
Doing this will change the .BackColor to "Control" but you can change that after if you want.
这样做会将.BackColor更改为“Control”,但您可以根据需要更改。
#2
13
Sorry for being late to the party, but the accepted answer didn't work for my needs. The following solution is what I came up with:
很抱歉迟到了,但接受的答案对我的需求不起作用。我想出了以下解决方案:
Getting rid of the black line
1) Create a custom renderer:
1)创建自定义渲染器:
class CustomToolStripProfessionalRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
// Don't draw a border
}
}
2) Use the custom renderer:
2)使用自定义渲染器:
toolStrip1.Renderer = new CustomToolStripProfessionalRenderer();
Getting rid of the background
The above solution satisfies the need of the original question, but I didn't like the gradient background on the ToolStrip either. I wanted the ToolStrip to be an "invisible" container:
上面的解决方案满足了原始问题的需要,但我也不喜欢ToolStrip上的渐变背景。我希望ToolStrip成为一个“隐形”容器:
1) Create a custom color table:
1)创建自定义颜色表:
class CustomProfessionalColorTable : ProfessionalColorTable
{
public override Color ToolStripGradientBegin
{
get { return SystemColors.Control; }
}
public override Color ToolStripGradientMiddle
{
get { return SystemColors.Control; }
}
public override Color ToolStripGradientEnd
{
get { return SystemColors.Control; }
}
}
2) Use the custom color table:
2)使用自定义颜色表:
class CustomToolStripProfessionalRenderer : ToolStripProfessionalRenderer
{
public CustomToolStripProfessionalRenderer()
: base(new CustomProfessionalColorTable())
{
}
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
// Don't draw a border
}
}
#3
3
I think your best shot would be to set the RenderMode
to System
in the properties and leave the layout properties to HorizontalStackWithOverflow
. But that is if you don't mind changing the tooltip paint style.
我认为你最好的方法是在属性中将RenderMode设置为System,并将布局属性保留为HorizontalStackWithOverflow。但那就是你不介意改变工具提示的绘画风格。