自定義tabcontrol實現

2021-07-26 18:32:54 字數 1414 閱讀 2739

using system;

using system.collections

.generic

;using system.drawing

;using system.linq

;using system.text

;using system.windows

.forms

;namespace shengxinsolution.client

.lableprintsystemv2

protected override void onpaint(painteventargs e)

//calculate text position

rectangle bounds = this.gettabrect(i);

pointf textpoint = new pointf();

sizef textsize = textrenderer.measuretext(this.tabpages[i].text, this.font);

//注意要加上每個標籤的左偏移量x

textpoint.x = bounds.x + (bounds.width - textsize.width) / 2

; textpoint.y = bounds.bottom - textsize.height - this.padding.y;

//draw highlights

e.graphics

.drawstring(

this.tabpages[i].text,

this.font,

systembrushes.controllightlight,

textpoint.x,

textpoint.y);

//繪製正常文字

textpoint.y--;

e.graphics

.drawstring(

this.tabpages[i].text,

this.font,

systembrushes.controltext,

textpoint.x,

textpoint.y);

//繪製圖示

if(this.imagelist!=null)

if (!string.isnullorempty(key))

e.graphics

.drawimage(

icon,

bounds.x + (bounds.width - icon.width) / 2,

bounds.top + this.padding

.y);}}

}}

}

分享一句最近比較喜歡的一句話

如果才華撐不起你的夢想,那就安靜下來讀書吧!

C 自定義重繪TabControl

using system.drawing using system.windows.forms using system.drawing.drawing2d using system.runtime.interopservices using system using system.drawing....

自定義Toast實現自定義Toast布局

平時我們使用toast的時候都是這樣的一種方法 toast toast toast.maketext context,duration 現在我們來自定義下toast的布局,首先看下toast建立時的源 public static toast maketext context context,char...

實現自定義IFormattable

using system using system.collections using system.linq using system.text using system.collections.generic using system.runtime.serialization namespac...