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
  1. Home
  2. General Programming
  3. C#
  4. Reach usercontrol's child control's methods

Reach usercontrol's child control's methods

Scheduled Pinned Locked Moved C#
question
7 Posts 5 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.
  • O Offline
    O Offline
    op75
    wrote on last edited by
    #1

    Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)

    L E S 3 Replies Last reply
    0
    • O op75

      Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)

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

      Why would you want to do this in the first place? And why do you think you will have to recode all the ListBox's methods? Isn't that why OOP includes inheritance?

      OriginalGriffO 1 Reply Last reply
      0
      • L Lost User

        Why would you want to do this in the first place? And why do you think you will have to recode all the ListBox's methods? Isn't that why OOP includes inheritance?

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Don't think he can inherit - sound like he is encapsulating the Listbox and a Scrollbar, so he can't inherit directly from the ListBox. Which means he has to provide pass-through methods or expose the ListBox directly - which he doesn't want to do.

        Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        L 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          Don't think he can inherit - sound like he is encapsulating the Listbox and a Scrollbar, so he can't inherit directly from the ListBox. Which means he has to provide pass-through methods or expose the ListBox directly - which he doesn't want to do.

          Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

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

          You may well be right.

          1 Reply Last reply
          0
          • O op75

            Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)

            E Offline
            E Offline
            Emre Ataseven
            wrote on last edited by
            #5

            If you want to access events of listbox in usercontrol without extra effort, not possible. If you want to access properties of listbox, create a property in Userclass.

            public ListBox listBox
            {
            get { return listBox1; }
            }

            and you need to define all required events;

            public event EventHandler ListBoxClick
            {
            add { listBox1.Click += value; }
            remove { listBox1.Click -= value; }
            }

            Tim Toady Bicarbonate

            1 Reply Last reply
            0
            • O op75

              Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)

              S Offline
              S Offline
              SledgeHammer01
              wrote on last edited by
              #6

              Learn WPF. This is EXACTLY what its intended for. ZERO C# to skin a control and its scrollbars.

              O 1 Reply Last reply
              0
              • S SledgeHammer01

                Learn WPF. This is EXACTLY what its intended for. ZERO C# to skin a control and its scrollbars.

                O Offline
                O Offline
                op75
                wrote on last edited by
                #7

                Thanks for all four replies ;) I came to the evidence that I need to learn WPF :)

                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