Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET TabControl
Hi all,
 
I have a problem on overriding method on vb.net
 
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 23:52pm

1 solution

Rate this: bad
good
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.)
  Permalink  
Comments
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 http://www.codeproject.com/Articles/20050/FireFox-like-Tab-Control 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 Sergey Alexandrovich Kryukov 609
1 OriginalGriff 587
2 Maciej Los 325
3 Mathew Soji 195
4 BillWoodruff 190
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2014
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