Hi!
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this);
this.Hide();
f2.Show(this);
}
This code replaces Form1 with Form2. But f2 shifts diagonally every time (
SetBounds(x,y,w,h) does not solve the problem.
If there anything like MasterPage in Web? Or how can I organize this, so while swithing between windows they remembered position (size).
Thanx!
9 replies to this topic
#1
Posted 21 July 2011 - 01:53 AM
|
|
|
#2
Posted 22 July 2011 - 06:23 AM
not sitting on my workstation, so I'll say this and sound like a dumbass more than likely =)
but have you tried the
or for some reason f2.Location is nagging me.
anyways, thats all I got from memory...
but have you tried the
f2.Top = X; ft.Left=Y;
or for some reason f2.Location is nagging me.
anyways, thats all I got from memory...
#3
Posted 26 July 2011 - 11:44 PM
shifting calls after X,Y definition.
And it is not the point. I would like to know, if anyone can tell how to work with many forms. How to make one template for them all.
new,show,close,setlocation,close,GC,show - is not the best way to do this I think.
Would be very thankful for some example or literature link.
And it is not the point. I would like to know, if anyone can tell how to work with many forms. How to make one template for them all.
new,show,close,setlocation,close,GC,show - is not the best way to do this I think.
Would be very thankful for some example or literature link.
#4
Posted 28 July 2011 - 03:30 PM
I'm not sure if you're asking about inheritance, or if you're wanting to retain reference to many forms, and then management externally.
eg inheritance
or if you mean just managing a collection of forms
I think you're asking about more the second. There are plenty of ways of doing this, and my specific way is more than likely not what you want to do. Just using it for the purposes of explanation.
What's throwing me off is your use of the MasterPage question I think. So it might be just a simple inheritance thing. In which case, just make your base form as you normally would. save and build the project.
then add a new inherited form, and select your base form as the base type. it has full designer support.
eg inheritance
class BaseForm : Form {
public void commonMethodA() {
}
public void commonMethodB() {
}
}
//Both of these form types inherit methods commonMethodA and commonMethodB
class SubFormTypeA : BaseForm {
}
class SuFormTypeB : BaseForm {
}
or if you mean just managing a collection of forms
List<Form> forms = new List<Form>();
forms.Add(new Form());
forms.Add(new Form());
forms.Add(new Form());
forms.Add(new Form());
forms.Add(new Form());
//then
void showAll() {
foreach (Form frm in forms) {
frm.Show();
}
}
void closeAll() {
foreach (Form frm in forms) {
frm.Close();
}
}
I think you're asking about more the second. There are plenty of ways of doing this, and my specific way is more than likely not what you want to do. Just using it for the purposes of explanation.
What's throwing me off is your use of the MasterPage question I think. So it might be just a simple inheritance thing. In which case, just make your base form as you normally would. save and build the project.
then add a new inherited form, and select your base form as the base type. it has full designer support.
#5
Posted 29 July 2011 - 06:17 AM
When you say "MasterPage" and "many forms", are you by any chance talking about Multiple Document Interface child forms?
How to: Create MDI Child Forms
How to: Create MDI Child Forms
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#6
Posted 29 July 2011 - 06:26 AM
I was thinking about that too greg, but a masterpage in ASP.NET is more of a template right?
So I was thinking perhaps he meant to style the form in a particular way, and each of the many forms would inherit those traits. I dunno... =)
Another thing that comes to mind, that I've seen (more in line with Greg's MDI suggestion than inheritance, but gives you the feel of an SDI) is to design the main form, with a big panel in the middle.
And then instead of creating forms, create user controls. You can then (just from memory, likely have something named wrong)
This kinda gives you the feel of outlook. As you switch between mail and calendar for example.
the idea being that you would create an instance of each of the user controls, and then you can just :
Course, My opinion on this is that the end product can look pretty, but it's likely way too much effort to give you the pay-off. =) but who knows, you might be feeling adventerious
Also note, you can in fact stick forms in a panel just like this, but I find it looks silly.
So I was thinking perhaps he meant to style the form in a particular way, and each of the many forms would inherit those traits. I dunno... =)
Another thing that comes to mind, that I've seen (more in line with Greg's MDI suggestion than inheritance, but gives you the feel of an SDI) is to design the main form, with a big panel in the middle.
And then instead of creating forms, create user controls. You can then (just from memory, likely have something named wrong)
Control myControl = new MyUserControl(); panel.Controls.Add(myControl); myControl.DockStyle = DockStyle.Fill;
This kinda gives you the feel of outlook. As you switch between mail and calendar for example.
the idea being that you would create an instance of each of the user controls, and then you can just :
panel.Controls.Remove(firstControl); panel.Controls.Add(secondControl); secondControl.DockStyle = DockStyle.Fill;
Course, My opinion on this is that the end product can look pretty, but it's likely way too much effort to give you the pay-off. =) but who knows, you might be feeling adventerious
Also note, you can in fact stick forms in a panel just like this, but I find it looks silly.
#7
Posted 31 July 2011 - 11:08 AM
I'm relatively novice developer. Multiform aplication organized by itself like this:
I've appointed first appeard form the Main Form, it'll live till the end of aplivation. All other forms are called by new, show() while the Main Form is hidden.
In fact there is no Main Form, all forms are equal. And it should be easy to navegate through them.
I thought the should be more proper way for this.
Inheritance and forms collection is a good advice and example. Thanks for push in right way. Adding and removing the controlls is a little bit hardcoding way, I prefer drag and drop :) But that is also by the topic. Work with control containers can be comfortable.
All told is good, thankee
I've appointed first appeard form the Main Form, it'll live till the end of aplivation. All other forms are called by new, show() while the Main Form is hidden.
In fact there is no Main Form, all forms are equal. And it should be easy to navegate through them.
I thought the should be more proper way for this.
Inheritance and forms collection is a good advice and example. Thanks for push in right way. Adding and removing the controlls is a little bit hardcoding way, I prefer drag and drop :) But that is also by the topic. Work with control containers can be comfortable.
All told is good, thankee
#8
Posted 31 July 2011 - 09:01 PM
are you talking about a sort of wizard?
Something very similar to like an installer?
like you have a back and next button at the bottom or something?
Something very similar to like an installer?
like you have a back and next button at the bottom or something?
#9
Posted 01 August 2011 - 05:48 AM
Program is look like many forms, where each form have a link to any other form.
Naturally form that opens should be the same size and position, like the one that had been closed.
Just like in games or any other program - if you resized the window before load the game, it'll stay resized when loaded) That is what I meant.
Do I need MDI Child Forms?
Maybe I'll just call forms without borders, that will dock to the Main Form (And Main Form will be empty)
Naturally form that opens should be the same size and position, like the one that had been closed.
Just like in games or any other program - if you resized the window before load the game, it'll stay resized when loaded) That is what I meant.
Do I need MDI Child Forms?
Maybe I'll just call forms without borders, that will dock to the Main Form (And Main Form will be empty)
#10
Posted 01 August 2011 - 07:56 AM
I'm on my way out to the beach. SO I cant do anything about this right now. But I'll throw a few samples together, and upload the solution here.
Maybe you could take a look for some ideas, or maybe just add onto one of them. I'm sure we could figure it out. =)
Maybe you could take a look for some ideas, or maybe just add onto one of them. I'm sure we could figure it out. =)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









