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. Quesions in this.Controls.Remove()/Add() ??

Quesions in this.Controls.Remove()/Add() ??

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

    Hi there, I hava a Form with 2 UserControls and 1 dialogBox. I want to use the DialogBox to set which UserControl will display on the Form. -UserControlA(a button: buttonToB) Form -UserControlB(a button: buttonToA) -DialogBox(2 buttons: Ok & Cancel) The Form will display UserControlA as StartUp, when buttonToB is clicked, the DialogBox appears, if Ok is pressed, then UserControlA will be removed and UserControlB will be add to the Form. I have public menthods in the Form as follows: public void RemoveUserControlA(){ this.Controls.Remove(UserControlA) // remove B UserControlA.Dispose(); } public void AddUserControlB(){ this.Controls.Add(UserControlB) } In the UserControlA, when the buttonToB is clicked private void buttonToB_click(){ if(dialog.Result == Ok){ Form f = new Form(); f.RemoveUserContorlA(); f.AddUserControlB(); } } Questions 1) How can I have some methods in the Form, and then invoke it in the UserContolA (i.e. public methods ?)? 2) How can I remove the Usercontrols using the dialog? 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