using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace NBTest
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.Height = 10;
createParams.Style |= (int) WindowStyles.WS_BORDER; return createParams;
}
}
[Flags()]
internal enum WindowStyles
{
WS_BORDER = 0x00800000
} public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
// 
// label1
// 
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "label1";
// 
// textBox1
// 
this.textBox1.Location = new System.Drawing.Point(24, 80);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(304, 112);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "textBox1";
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(352, 224);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
}
}
}

解决方案 »

  1.   

    虽然createParams.Height = 10;
    可显示出来还是20多
      

  2.   

    估计是控件内部set{}时写的判断吧, 小于27的高度, 自动设置成27
      

  3.   

    属性 DefaultSize 或者 MinimumSize 在起作用。可以通过调试,查看一下 Form 的 DefaultSize 和 MinimumSize 的 Height 是不是 27。
    找到了,作相应适当的修正。
      

  4.   

    DefautSize.Height是300
    MinimunSize.Height是0
    和27没什么关系啊