c# form linking - assistance required

Associate
Joined
8 Sep 2011
Posts
1,935
Location
Northern Ireland
c# noob here but Basically im trying to link forms together

so far i managed to do the following:
add the following code to first form
Code:
Form2 form = new Form2();
form.Show();

it shows the Form2 fine but the first form is still there
I tried adding
Code:
this.Hide()
in the first form but whenever I close Form2 I can still see the form1 in task manager. I tried using this.Close() instead of the hide but it closes both forms

WHat im trying to achieve is when the user clicks Next in the form1 it disappears from view and form2 appears. Like the one from installers where i can click next and back.

Thanks
 
Try this, I haven't got VS open though...

Form1.Hide();
Form2.ShowInTaskbar = false;
Form2.ShowDialog();

thanks but isnt the Form1.Hide() from ur code the same as the this.Hide() from mines?

So far I have manage to create what I want to happen but im using loads of panels. Ive been using

panel2.Visible = true;
panel1.Visible = false;

when the user click Next

The effect is good but adding buttons / txt boxes on 5 different layers of panel is a nightmare lol I would image the coding will be the same
 
I'm not very experienced in C# but this.Hide(); should work. It works in a quick one I just made. Where are you still seeing form1 in task manager?

I found that tab panels were easier to use than panels and all you then do is hide the tabs on the top so user can't click between them that way. Allows you to edit each tab individually and not start overlaying stuff.


lets say form1 and form2 belongs to Registration solution
I ran the program with a form1.Hide() code line for the Next button the form1 disappears but when I hit Close on form2 i can still see the process Registration.exe on the task manager even though I hit close.

Also there are times that when I build the solution an error will come up saying it failed to build because something is still in process.

Anyways I found the control tab feature you were saying about an hour ago and I must say its a lot easier compared to using panel layers :D

As of now im currently transferring all my buttons and labels from panel to the tabs. Just need to figure out the different controls to change tabs when using Next / Previous buttons

Thanks all
 
I think the exit 'X' button on a form only shuts that form down. It only ends the application exe IF that form is the starting form. I am not experienced enough to know how to get around this apart from your own exit button that then uses Application.exit();

For changing the visible tab you used TabControl1.SelectedIndex = X; as far as I remember (Not near my PC at the moment).

no problems there

will the TabControl1.SelectedIndex = X; make the tab header hidden so the user cant see it and must use my Next button or the whole tab will be hidden ?

I found a Visible property in my tabcontrol but it made everything invisible lol
 
Ah yes sorry it isn't as easy as it was in VB 2008, which had an option to just hide them.

You have to create your own class and then use that, if you follow the instructions at this link http://www.mostthingsweb.com/2011/01/hiding-tab-headers-on-a-tabcontrol-in-c/ then you shouldn't need to redo all the tabs and it will remove the tab headers. Page also explains what it is doing.

Hope this helps.

Sweet!! thanks for the link! Ive been looking for that for ages in different coding sites

Thanks a lot!! :)
 
Back
Top Bottom