TabControl close button
Posted: Sat Apr 28, 2012 11:41 am
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