就像comboBox控件一样.无法设置其高度

解决方案 »

  1.   

    在OnPaint()里面设置Height=xxx ,Width =xxx
      

  2.   

    或者在Resize 里面设置也都可以.
      

  3.   

    用2.0就好办了,this.MinimumSize = this.MaximumSize = new Size(0, fixedHeightValue);
      

  4.   

    啊,看到了一个1.x里面也能用的办法示例
    下面的代码示例重写 SetBoundsCore 方法,以确保控件保持固定的大小。该示例要求有从 Control 类直接或间接派生的类。C#
    protected override void SetBoundsCore(int x, int y, 
       int width, int height, BoundsSpecified specified)
    {
       // Set a fixed height and width for the control.
       base.SetBoundsCore(x, y, 150, 75, specified);

    同理,只固定高度的话,将width放回调用处即可
      

  5.   

    无论是设计时还是运行时OnPaint都可以搞定
      

  6.   

    TO:netmicro(麦) 
    我这样写,好像不起作用.TO:storm97(风暴不再)
    效率太低.
      

  7.   

    storm97(风暴不再) 的方法可以,要嫌效率低的话,可以先判一下,
    if( Height!=xxx ) Height=xxx ;
      

  8.   

    只要重写SetBoundsCore方法即可.
      

  9.   

    回楼上的,楼主之前说了SetBoundsCore“好像不起作用”