TabControl close button
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
5 posts
Page 1 of 1
Lets get started....
First add class and name it xTabControl. And inherit it to Tabcontrol
now, on controls paint event add this code that paints X button
that will draw two lines that looks like X.
Now add mouse move event and add this code.
this will add highliht animatoin.
Now just add mouse down and mouse click event.
In mouse down event add this.
And one more thing for actual tab close. On mouseclick add
First add class and name it xTabControl. And inherit it to Tabcontrol
Code: Select all
Public class xTabControl
inherits tabcontrol
end class
now, on controls paint event add this code that paints X button
Code: Select all
for i as integer= 0 to tabcount-1
e.graphics.drawline(gettabrect(i).right-10,5,gettabrect(i).right - 4,11)
e.graphics.drawline(gettabrect(i).right-4,5,gettabrect(i).right - 10,11)
next
that will draw two lines that looks like X.
Now add mouse move event and add this code.
Code: Select all
for i as integer 0 to tabcount -1
dim r as rectangle.equals(gettabrect(i))
dim r2 as new rectangle(r.righ-10,5,6,6)
if r2.contains(e.location) then
dim g as graphics=creategraphics
G.drawrectangle(new pen(color.fromaqgb(0,0,0),r2)
else
invalidate(r2)
end if
next
this will add highliht animatoin.
Now just add mouse down and mouse click event.
In mouse down event add this.
Code: Select all
for i as integer 0 to tabcount -1
dim r as rectangle.equals(gettabrect(i))
dim r2 as new rectangle(r.righ-10,5,6,6)
if r2.contains(e.location) then
dim g as graphics=creategraphics
G.fillrectangle(new solidbrush(color.red),r2)
else
invalidate(r2)
end if
next
And one more thing for actual tab close. On mouseclick add
Code: Select all
The code is not tested I typed it up at school while I was borred.for I as integer= 0 to tabcount -1
dim r as rectangle.equals(gettabrect(i))
dim r2 as new rectangle(r.righ-10,5,6,6)
if r2.contains(e.location) then
Tabpages.removeat(i)
Exit sub
End if
next
Code: Select all
Is wrong. Replace ".equals" with " = "dim r as rectangle.equals(gettabrect(i))
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

I've tried this before, but my problem has always been to detect when the tab page has been closed, so that I could run code based on that event. Any ideas?
Well, you could do something before the tabpages.removeat(i)
like if msgbox(quit,yesno) = ok then tabpages.removeat(i)
like if msgbox(quit,yesno) = ok then tabpages.removeat(i)
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023