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. Re:Displaying child windows

Re:Displaying child windows

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

    hi can anybody let me know is it possible to display child windows using threads or delegates? thanks

    R C D 4 Replies Last reply
    0
    • R RameshwerE

      hi can anybody let me know is it possible to display child windows using threads or delegates? thanks

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

      why would you need to do that anyway? just display the child window like this form1.Show(this) to make it a child window of the current window that;s it

      Rocky You can't climb up a ladder with your hands in your pockets.

      1 Reply Last reply
      0
      • R RameshwerE

        hi can anybody let me know is it possible to display child windows using threads or delegates? thanks

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        RameshwerE wrote:

        threads or delegates?

        These are two utterly, totally different things. The latter is trivial, the former is a bad move. You should never interact with UI elements outside of the thread that created them, which should, logically, be your main thread.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • R RameshwerE

          hi can anybody let me know is it possible to display child windows using threads or delegates? thanks

          D Offline
          D Offline
          Doug Chen
          wrote on last edited by
          #4

          A simple way to do it using timer... it's like a thread via timer, is it useful to you ? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Imaging; namespace OptionFormA { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { Timer t = new Timer(); t.Tick += new EventHandler(FormOpen); t.Start(); } private void FormOpen(object _sender, EventArgs eArgs) { SubFormA sfA = new SubFormA(); sfA.Visible = true; } } }

          By AYR itsayr@gmail.com

          1 Reply Last reply
          0
          • R RameshwerE

            hi can anybody let me know is it possible to display child windows using threads or delegates? thanks

            D Offline
            D Offline
            Doug Chen
            wrote on last edited by
            #5

            But I have a question about if i want appear a form after pressing a button on main form and main form will disappear, and when press a button on child form the child form will disappear and the main form will appear ? Does anyone know how to do?

            By AYR itsayr@gmail.com

            H 1 Reply Last reply
            0
            • D Doug Chen

              But I have a question about if i want appear a form after pressing a button on main form and main form will disappear, and when press a button on child form the child form will disappear and the main form will appear ? Does anyone know how to do?

              By AYR itsayr@gmail.com

              H Offline
              H Offline
              Hessam Jalali
              wrote on last edited by
              #6

              just pass the main form to child form and then call Hide method of the main through child or before showing it (from the MainForm) and you can do that vice versa for showing main again and hiding child

              namespace Test2
              {

              public partial class MainForm : Form
              {
                  ChildForm child;
              
                  public MainForm()
                  {
                      InitializeComponent();
                      this.child = new ChildForm(this);
                  }
              
                  private void hideAndShowChld\_Click(object sender, EventArgs e)
                  {
                      this.Hide();
                      this.child.Show();
                  }
              }
              
              
              
              public partial class ChildForm : Form
              {
                  MainForm main;
              
                  public ChildForm(MainForm form)
                  {
                      InitializeComponent();
                      this.main = form;
                  }
              
                  private void button1\_Click(object sender, EventArgs e)
                  {
                      this.Hide();
                      this.main.Show();
              
                  }
              }
              

              }

              good luck

              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