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. how to remove the control from the winform by clicking the button on the control in the desin environment

how to remove the control from the winform by clicking the button on the control in the desin environment

Scheduled Pinned Locked Moved C#
designtutorialquestionworkspace
5 Posts 4 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.
  • M Offline
    M Offline
    mctramp168
    wrote on last edited by
    #1

    Dear All: I create a usercontrol , there is a button in it, I place this control on one winform,I want to remove the control from the winform by clickinng the button on the control in design environment, how to write the code under the button_Click? Thanks in advance! Tramp

    R T D 3 Replies Last reply
    0
    • M mctramp168

      Dear All: I create a usercontrol , there is a button in it, I place this control on one winform,I want to remove the control from the winform by clickinng the button on the control in design environment, how to write the code under the button_Click? Thanks in advance! Tramp

      R Offline
      R Offline
      rah_sin
      wrote on last edited by
      #2

      i think u can use Form.Controls.Remove(index) ;

      rahul

      1 Reply Last reply
      0
      • M mctramp168

        Dear All: I create a usercontrol , there is a button in it, I place this control on one winform,I want to remove the control from the winform by clickinng the button on the control in design environment, how to write the code under the button_Click? Thanks in advance! Tramp

        T Offline
        T Offline
        Tom Deketelaere
        wrote on last edited by
        #3

        Well first you don't put the code for this in the control (bad habit). You expose a event on your control, the button click raises this event. Then on the form that contains the control you catch this event and there you write the code to remove the control. From memory (so you might want/need to adjust it a bit)

        'in the event off the control
        'customcontrol = the name of your control as it is named on the form
        controls.remove(custumcontrol);

        You can also pass along the name of the control in the event, then you can replace 'customcontrol' with that. Hope this helps [EDIT]Adjust the code to c# (forgot I wasn't in the vb.net forum :) [/EDIT]

        1 Reply Last reply
        0
        • M mctramp168

          Dear All: I create a usercontrol , there is a button in it, I place this control on one winform,I want to remove the control from the winform by clickinng the button on the control in design environment, how to write the code under the button_Click? Thanks in advance! Tramp

          D Offline
          D Offline
          Dragonfly_Lee
          wrote on last edited by
          #4

          mctramp168 wrote:

          in design environment

          You really want to do this in design enviroment rather than pressing the ‘Delete’ buttono?

          :) I Love KongFu~

          M 1 Reply Last reply
          0
          • D Dragonfly_Lee

            mctramp168 wrote:

            in design environment

            You really want to do this in design enviroment rather than pressing the ‘Delete’ buttono?

            :) I Love KongFu~

            M Offline
            M Offline
            mctramp168
            wrote on last edited by
            #5

            thanks, I only want to know how to realize this function.

            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