Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Inheriting from the tabcontrol

Inheriting from the tabcontrol

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thepersonof
    wrote on last edited by
    #1

    Hi I have I a class that inherits from TabConrol called MyControl. I have a class that inherits from TabPage called MyTabPage, as below: (heavily simplified) class MyTabControl:TabControl { protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs ke) { (this.SelectedTab as MyTabPage).PanelContained.KDown(ke); base.OnKeyDown(ke); } } class MyTabPage : TabPage { private MyPanel panelContained; public MyPanel PanelContained{ get { return panelContained; } set { panelContained = value; } } } How can I override SelectedTab to return a MyTabPage? If I add a MyTabPage and change the panelcontained property, this is null again when I convet it back from SelectedTab. Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property? cheeers

    L 1 Reply Last reply
    0
    • T thepersonof

      Hi I have I a class that inherits from TabConrol called MyControl. I have a class that inherits from TabPage called MyTabPage, as below: (heavily simplified) class MyTabControl:TabControl { protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs ke) { (this.SelectedTab as MyTabPage).PanelContained.KDown(ke); base.OnKeyDown(ke); } } class MyTabPage : TabPage { private MyPanel panelContained; public MyPanel PanelContained{ get { return panelContained; } set { panelContained = value; } } } How can I override SelectedTab to return a MyTabPage? If I add a MyTabPage and change the panelcontained property, this is null again when I convet it back from SelectedTab. Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property? cheeers

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      thepersonof wrote:

      How can I override SelectedTab to return a MyTabPage?

      You can't change the return type or the method parameter types in an overload.

      thepersonof wrote:

      Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property?

      TabControl tabs = new MyTabPage(); //ok since TabControl is a base class Since tab control does not have the PanelContained property you will not beable to use it in tabs unless its cast back up to MyTabPage. Even though the compatible TabControl contains a MyTabPage the PanelContained property will not be exposed. You will have to do this. ((MyTabPage)tabs).PanelExposed

      █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

      T 1 Reply Last reply
      0
      • L Lost User

        thepersonof wrote:

        How can I override SelectedTab to return a MyTabPage?

        You can't change the return type or the method parameter types in an overload.

        thepersonof wrote:

        Seeing as it inherits from TabControl is there a nice way to make it so that I can convert it back into a MyTabPage without losing the added property?

        TabControl tabs = new MyTabPage(); //ok since TabControl is a base class Since tab control does not have the PanelContained property you will not beable to use it in tabs unless its cast back up to MyTabPage. Even though the compatible TabControl contains a MyTabPage the PanelContained property will not be exposed. You will have to do this. ((MyTabPage)tabs).PanelExposed

        █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

        T Offline
        T Offline
        thepersonof
        wrote on last edited by
        #3

        Thank you. I can't manage to make the method you suggest work, does anyone have any other suggestions? thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups