小智 10
您重写SetBoundsCore并定义Designer以删除顶部和底部调整大小句柄.
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace MyControlProject
{
[Designer(typeof(MyControlDesigner))]
public class MyControl : Control
{
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
height = 50;
base.SetBoundsCore(x, y, width, height, specified);
}
}
internal class MyControlDesigner : ControlDesigner
{
MyControlDesigner()
{
base.AutoResizeHandles = true;
}
public override SelectionRules SelectionRules
{
get
{
return SelectionRules.LeftSizeable | SelectionRules.RightSizeable | SelectionRules.Moveable;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
试试这个
protected override void SetBoundsCore(int x, int y,
int width, int height, BoundsSpecified specified)
{
// Set a fixed height for the control.
base.SetBoundsCore(x, y, width, 75, specified);
}
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setboundscore(VS.71).aspx
| 归档时间: |
|
| 查看次数: |
7550 次 |
| 最近记录: |