Цвет вкладки синий, и я хочу его изменить
Это элемент управления вкладками, который я использую:
https://www .codeproject.com/Articles/91387/Painting-Your-Own-Tabs-Second-Edition
Это моя попытка изменить это, но мне это не удалось:
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Microsoft.Web.WebView2.Core;
using TradeWright.UI.Forms;
namespace myapp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Set the DrawMode to OwnerDrawFixed to enable custom drawing of tabs
tabControlExtra1.DrawMode = TabDrawMode.OwnerDrawFixed;
tabControlExtra1.DrawItem += tabControl_DrawItem;
tabControlExtra1.SelectedIndexChanged += tabControl_SelectedIndexChanged;
}
private void tabControl_DrawItem(object sender, DrawItemEventArgs e)
{
TabPage tabPage = tabControlExtra1.TabPages[e.Index];
Rectangle tabRect = tabControlExtra1.GetTabRect(e.Index);
// Check if the tab is selected
bool isSelected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
// Set the background color
Color backColor = isSelected ? Color.Black : tabPage.BackColor; // Change to your desired color
using (SolidBrush brush = new SolidBrush(backColor))
{
e.Graphics.FillRectangle(brush, tabRect);
}
// Draw the tab text
TextRenderer.DrawText(e.Graphics, tabPage.Text, tabPage.Font, tabRect,
tabPage.ForeColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
}
private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
{
// Force the tab control to redraw itself
tabControlExtra1.Refresh(); // Changed from Invalidate to Refresh
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... rite-tabco
Как изменить цвет вкладок для пользовательского элемента управления вкладками, называемого tradewrite tabcontrol? ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение