簡體   English   中英

C#tabcontrol邊框控件

[英]C# tabcontrol border controls

是否可以使tabcontrol邊框透明或設置tabcontrol的顏色?

  • 的WinForms

如果有人遇到相同的問題,這是對我有用的答案Border TabControl

如其描述,創建一個NativeTabControl對象並分配要刪除其邊框的tabControl的句柄。 您可以將此NativeTabControl類用作表單類中的內部類。 您無需在內部類中進行任何更改。 只需按照上述步驟。 所有的功勞應該歸於代碼的原始設計者。 我只是將它放在這里,供那些遇到相同問題並需要一個漂亮性感的答案的人使用!

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public class Form1
{


public Form1()
{
    // This call is required by the Windows Form Designer.
    InitializeComponent();

    // Add any initialization after the InitializeComponent() call.
    this.NativeTabControl1 = new NativeTabControl();
    this.NativeTabControl2 = new NativeTabControl();
    this.NativeTabControl1.AssignHandle(this.TabControl1.Handle);
    this.NativeTabControl2.AssignHandle(this.TabControl2.Handle);
}

private NativeTabControl NativeTabControl1;

private NativeTabControl NativeTabControl2;
private class NativeTabControl : NativeWindow
{

    protected override void WndProc(ref Message m)
    {
        if ((m.Msg == TCM_ADJUSTRECT)) {
            RECT rc = (RECT)m.GetLParam(typeof(RECT));
            //Adjust these values to suit, dependant upon Appearance
            rc.Left -= 3;
            rc.Right += 3;
            rc.Top -= 3;
            rc.Bottom += 3;
            Marshal.StructureToPtr(rc, m.LParam, true);
        }
        base.WndProc(ref m);
    }

    private const Int32 TCM_FIRST = 0x1300;
    private const Int32 TCM_ADJUSTRECT = (TCM_FIRST + 40);
    private struct RECT
    {
        public Int32 Left;
        public Int32 Top;
        public Int32 Right;
        public Int32 Bottom;
    }

}

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM