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. Add control to form ,from UserControl

Add control to form ,from UserControl

Scheduled Pinned Locked Moved C#
designquestion
6 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.
  • S Offline
    S Offline
    Said Ali Jalali
    wrote on last edited by
    #1

    :rose: Hi. I have a User Control and i added it to my Tool Box.When you add this control to your form, user control shows a form with 1 button. I want to click the button and one Text Box be added on the Main Form(Form1). How can get the form in that time(from my User Control)?? This is Design time!! Thank you. :rose: CanI

    OriginalGriffO S 2 Replies Last reply
    0
    • S Said Ali Jalali

      :rose: Hi. I have a User Control and i added it to my Tool Box.When you add this control to your form, user control shows a form with 1 button. I want to click the button and one Text Box be added on the Main Form(Form1). How can get the form in that time(from my User Control)?? This is Design time!! Thank you. :rose: CanI

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

      Repost! Don't post in more than one place - all you do is duplicate work and annoy people. Either post in the forums, or in Q&A. But not both.

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "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

      S 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Repost! Don't post in more than one place - all you do is duplicate work and annoy people. Either post in the forums, or in Q&A. But not both.

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        S Offline
        S Offline
        Said Ali Jalali
        wrote on last edited by
        #3

        :rose: Sorry,My connection broke and i thought it wasn't saved. :rose: CanI

        A 1 Reply Last reply
        0
        • S Said Ali Jalali

          :rose: Sorry,My connection broke and i thought it wasn't saved. :rose: CanI

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #4

          Fair enough - I've upvoted your question to counter the one vote. However, you can do away with the flowers in your question (if possible) though.

          The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

          1 Reply Last reply
          0
          • S Said Ali Jalali

            :rose: Hi. I have a User Control and i added it to my Tool Box.When you add this control to your form, user control shows a form with 1 button. I want to click the button and one Text Box be added on the Main Form(Form1). How can get the form in that time(from my User Control)?? This is Design time!! Thank you. :rose: CanI

            S Offline
            S Offline
            Shuaib wasif khan
            wrote on last edited by
            #5

            i can not understand your question . plz provide more details

            S 1 Reply Last reply
            0
            • S Shuaib wasif khan

              i can not understand your question . plz provide more details

              S Offline
              S Offline
              Said Ali Jalali
              wrote on last edited by
              #6

              :rose: Hi. Let me tell you again. I create a UserControl .OK!. In Load event i write this:

                   private void UserControl1\_Load(object sender, EventArgs e)
                  {
                   //Add Form1 to your UserControl with one Button on(button 1) it.Think we did design it. 
                   Form1 f1=new Form1(); 
                   f1.Show Dialog();
                  }
              

              And now in that button(f1.button1) write this:

                  private void button1\_Click(object sender, EventArgs e)
                  {
                     TextBox textBox= new TextBox();
                     textBox.Text="Name";
                     //And now work start.
                     //Now i want to get the Form that you add the **UserControl** on it,Got it??The Main Form that Contain the UserControl. 
                      //Form1 or any other name
                      Form1 f1=new Form1();
                      f1.Controls.Add(textBox);
                      //
                  }
              

              The question is How to get that form and throw(Add) the textBox on it!!We don't have it now!!??What a code should we write? I hope you understand what i am telling you. Thank you. :rose: CanI

              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