我怎样才能让WinForms的TabPage的头宽度适合它的标题? [英] How can i make WinForms TabPage header width fit it's title?

查看:406
本文介绍了我怎样才能让WinForms的TabPage的头宽度适合它的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能让WinForms的TabPage的头宽度适合它的标题?
这是问题所在。

How can i make WinForms TabPage header width fit it's title? Here is the problem.

推荐答案

本地的Windows标签控件允许覆盖默认的最小宽度标签。可悲的是这种能力不是在TabControl的包装类暴露出来。这是可以解决的,但。添加一个新类到您的项目并粘贴如下所示的代码。编译。 。从工具箱到窗体顶部的新的控制

The native Windows tab control allows overriding the default minimum tab width. Sadly that capability is not exposed in the TabControl wrapper class. That's fixable though. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.

using System;
using System.Windows.Forms;

class MyTabControl : TabControl {
    protected override void OnHandleCreated(EventArgs e) {
        base.OnHandleCreated(e);
        // Send TCM_SETMINTABWIDTH
        SendMessage(this.Handle, 0x1300 + 49, IntPtr.Zero, (IntPtr)10);
    }
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
}

这篇关于我怎样才能让WinForms的TabPage的头宽度适合它的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆