TabControl怎样设选中哪一个TAB就用红色把它明显出来。

nternter 2003-04-09 06:03:48
TabControl怎样设选中哪一个TAB就用红色把哪一项TAB显出来。
...全文
167 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
findcsdn 2003-04-09
  • 打赏
  • 举报
回复
// ownerdraw := True;

// 写OnDrawTab事件;
procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
Tmp: Integer;
rec: TRect;
begin
Tmp := TabIndex;
Rec := Rect;
with Control as TTabControl do
begin
if active then
begin
Canvas.Brush.Color := clbtnface;
canvas.FillRect(Rect);
Canvas.Brush.Color := clred;
Dec(Rec.Bottom, 3);
canvas.FillRect(Rec);
canvas.TextOut(rect.Left + 7, rect.Top + 4, Tabs.Strings[Tmp]);
end
else begin
Canvas.Brush.Color := clbtnface;
canvas.FillRect(rect);
canvas.TextOut(rect.Left + 3, rect.Top + 4, Tabs.Strings[Tmp]);
end;
end;
end;
sysu 2003-04-09
  • 打赏
  • 举报
回复
设置TabControl的OwnerDraw属性为True,在它的OnDrawTab事件中:
procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
begin
with TabControl1.Canvas do begin
if Active then
Brush.Color := clRed;
FillRect(Rect);
if Active then
TextOut(Rect.Left+5, Rect.Top+5, TabControl1.Tabs[TabIndex])
else
TextOut(Rect.Left+3, Rect.Top+3, TabControl1.Tabs[TabIndex]);
end;
end;

另外PageControl也是一样的。
delphiyesgood 2003-04-09
  • 打赏
  • 举报
回复
if PageControl1.ActivePageIndex = 0 then
.......................................
if PageControl1.ActivePageIndex = 1 then
.......................................
delphiyesgood 2003-04-09
  • 打赏
  • 举报
回复
if TabControl1.ActivePageIndex = 0 then
.......................
myling 2003-04-09
  • 打赏
  • 举报
回复
首先,TabControl是一个单独的对象,想改变单个标签,请使用pagecontrol

其次,如果确实想改变,在 onchange 事件中改变
nternter 2003-04-09
  • 打赏
  • 举报
回复
请详述!
xiaohuan 2003-04-09
  • 打赏
  • 举报
回复
用tabset配合着用

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧