标签页页眉位置 [英] Tab Page Header Location

查看:123
本文介绍了标签页页眉位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单中有一个Tab控件,我想要实现的一种简单方法是获取Tab页面页眉的确切位置.

I have a Tab Control in my Form and what I want to achieve is a simple way to get the exact location the Tab Page Header.

我已经搜索了,但是什么也没找到.有什么想法吗?

I've searched around, but I haven't found anything. Any ideas?

推荐答案

这将使 Tab 控件 blink 稍微变一点,但它将返回边界矩形的列表页面的标题.

This will make the Tab control blink a little but it will return a list of bounding Rectangles for the pages' headers..

SortedDictionary<int, Rectangle> GetTabBounds(TabControl tab)
{
    SortedDictionary<int, Rectangle> bounds = new SortedDictionary<int, Rectangle>();
    TabDrawMode tdm = tab.DrawMode;
    tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed;
    DrawItemEventHandler mit = (sl, el) => bounds.Add(el.Index, el.Bounds);
    tab.DrawItem += mit;
    tab.Refresh();
    tab.DrawItem -= mit;
    tab.DrawMode = tdm;
    tab.Invalidate();
    return bounds;
}

对于不太准确的结果,您可能只想根据页面索引和标签项的大小来计算它们.至少,如果您的页面全部位于同一行中.

For a less exact result you may simply want to calculate them from the page index and tab item size..at least if your pages are all in one row.

这篇关于标签页页眉位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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