Click here to Skip to main content
13,145,068 members (54,460 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 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 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 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)

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2017
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