Click here to Skip to main content
11,802,389 members (30,368 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB VB.NET TabControl
Hi all,

I have a problem on overriding method on

Here's the code :
Protected Overrides Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
       MsgBox("Draw Item")
   End Sub

It throw me error :
Error 1 sub 'TabControl1_DrawItem' cannot be declared 'Overrides' because it does not override a sub in a base class. C:\Users\satrio.budiharmawan\AppData\Local\Temporary Projects\sieg01\Form1.vb 39 29 sieg01

The question is, how do I overrides that method?
Posted 6-Jan-13 22:52pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you are overriding the DrawItem method you would override Protected Overrides Sub DrawItem..., but only if the class you are writing derives from TabControl.
If this is a Form where you simply want to create a handler for the TabControl1.DrawItem method, then just remove the Overrides from your sub definition. (This second point is what I think is more likely.)
satrio_budidharmawan at 7-Jan-13 21:10pm
Well, what i tried to do is adding something to my tabpage (close button, just like tab in browser, such as Firefox). So in that case, according to this article I need to overrides that method.
Marcus Kramer at 8-Jan-13 10:19am
As I said in my answer already, if you are writing this code in a class that inherits from TabControl then you need to override, but I suspect that you have placed a TabControl on your Form/UserControl and are trying to get to the DrawItem of the TabControl that way. In that situation, you need to take the Overrides out and attach the DrawItem event for the TabControl to your method.
satrio_budidharmawan at 8-Jan-13 20:08pm
ah, I just realized what you meant on your answer..hahaha,
So, I need to create my tabControl on the fly?not attach it on my form from designer?
But yes I've tried to write my code on TabControl1_OnDrawItem which created by .Net, but it didn't work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 475
1 KrunalRohit 366
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CHill60 220
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,645
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100