gpt4 book ai didi

.net - 具有 Appearance=Buttons 的 Windows TabControl,在右侧获得较大的边距

转载 作者:行者123 更新时间:2023-12-03 23:46:09 25 4
gpt4 key购买 nike

我正在创建 Windows C#/.NET 应用程序,我正在尝试使用外观设置为按钮的 TabControl。我希望标签只有图像,没有文字。但是,我在每个按钮的右侧得到了一堆额外的填充,我想去掉它们:

enter image description here
我可以通过将字体大小减小到 1 来减小右边距,但它仍然比左侧宽几个像素,而且看起来有点笨拙。有没有更好的办法?

最佳答案

试试这个

public frmForm()
{
InitializeComponent();
tabControl1.Appearance = TabAppearance.Buttons;
tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed;
tabControl1.DrawItem += new DrawItemEventHandler(tabControl1_DrawItem);
}

private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
//Load the image
Image img = Image.FromFile(String.Format("{0}\\{1}.jpg",Application.StartupPath,tabControl1.TabPages[e.Index].Name));
//Resize image
img = new Bitmap(img, e.Bounds.Size);
//Draw on Tab Button
e.Graphics.DrawImage(img, e.Bounds.Location);
}

enter image description here

关于.net - 具有 Appearance=Buttons 的 Windows TabControl,在右侧获得较大的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17999109/

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