gpt4 book ai didi

C# tabcontrol 边框控件

转载 作者:行者123 更新时间:2023-12-05 01:22:07 24 4
gpt4 key购买 nike

是否可以使 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;
}

}

关于C# tabcontrol 边框控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2567172/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com