C# calling forms
-
in c# i created the first form as a login the second displays a buddy list once you login the first form is hiden using Form1.hide(); now on the second one i have a log out button that i want to close the second form and open the original first form not a new object i have everything done but reopening the first form. thank you if you can help
-
in c# i created the first form as a login the second displays a buddy list once you login the first form is hiden using Form1.hide(); now on the second one i have a log out button that i want to close the second form and open the original first form not a new object i have everything done but reopening the first form. thank you if you can help
-
Gregory Bryant wrote:
the first form is hiden using Form1.hide();
Gregory Bryant wrote:
open the original first form not a new object
Form1.Show();
led mike
i am trying to open the first form from the second that does not work i get an error An object reference is required but i dont want to creat a new object and i do not know how to get the orginal object from my second form
-
i am trying to open the first form from the second that does not work i get an error An object reference is required but i dont want to creat a new object and i do not know how to get the orginal object from my second form
Gregory Bryant wrote:
and i do not know how to get the orginal object from my second form
that's an Object Oriented Programming beginners issue. You need a C# book for beginners. Trying to learn programming fundamentals over the internet forums is not an efficient means of doing that.
led mike
-
in c# i created the first form as a login the second displays a buddy list once you login the first form is hiden using Form1.hide(); now on the second one i have a log out button that i want to close the second form and open the original first form not a new object i have everything done but reopening the first form. thank you if you can help
I'm going to suggest that you use one of the design patterns here. One that I'm thinking might help is the Mediator pattern (have a look on Google to find it), but it basically looks like this:
public class Mediator
{
private Form1 _loginForm;
private Form2 _buddyForm;public Form2 BuddyForm
{
get
{
if (_buddyForm == null)
_buddyForm = new Form2(this);
return _buddyForm;
}
}
public Form1 LoginForm
{
get
{
if (_loginForm == null)
_loginForm = new Form1(this);
return _loginForm;
}
}public void Logout()
{
LoginForm.Show();
BuddyForm.Hide();
}
// You get the idea for the rest anyway...
}public class Form1 : Form
{
private Mediator _mediator;
public Form1(Mediator mediator)
{
_mediator = mediator;
}// Some code to respond to a button for instance
protected virtual void Login_Click(object sender, EventArgs e)
{
_mediator.ShowBuddy();
}
}public class Form2 : Form
{
private Mediator _mediator;
public Form2(Mediator mediator)
{
_mediator = mediator;
}// Some code to respond to a button for instance
protected virtual void Logout_Click(object sender, EventArgs e)
{
_mediator.Logout();
}
}Deja View - the feeling that you've seen this post before.
-
Gregory Bryant wrote:
and i do not know how to get the orginal object from my second form
that's an Object Oriented Programming beginners issue. You need a C# book for beginners. Trying to learn programming fundamentals over the internet forums is not an efficient means of doing that.
led mike
so in other words you dont know thanks lol
-
so in other words you dont know thanks lol
-
so in other words you dont know thanks lol
Do you see that funky shaped icon beside his name? That means he does know - he's just not sure you're capable of this yourself.
Deja View - the feeling that you've seen this post before.
-
Do you see that funky shaped icon beside his name? That means he does know - he's just not sure you're capable of this yourself.
Deja View - the feeling that you've seen this post before.
well the fuction he is trying to tell me to use is Visual basic function try it your self works fine in VB but not C++ or C# which i was asking about
-
Do you see that funky shaped icon beside his name? That means he does know - he's just not sure you're capable of this yourself.
Deja View - the feeling that you've seen this post before.
which funky do you mean, AE or BE? if I'm getting insulted, at least let me know and prepare for a fearless riposte. :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
well the fuction he is trying to tell me to use is Visual basic function try it your self works fine in VB but not C++ or C# which i was asking about
I hate to tell you this, but it's a method on the Form class, and does work in C#. I've used it often enough to recognise it.
Deja View - the feeling that you've seen this post before.
-
well the fuction he is trying to tell me to use is Visual basic function try it your self works fine in VB but not C++ or C# which i was asking about
Wrong. I have a C# Windows Forms application that I executed that code in before I posted it to you. I am trying hard not to insult you ( no comments needed from you Pete :-D ), I really mean it sincerely when I suggest you need to use a beginners book. There is nothing wrong with that, I still have shelves of them at home from when I started and I still have to look things up in them almost 20 years later! :laugh: It's a never ending experience learning about development but we really need a foundation to work from.
led mike
-
which funky do you mean, AE or BE? if I'm getting insulted, at least let me know and prepare for a fearless riposte. :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
Funky as in classy shaped icon. No insults there - just 3 MVPs chewing the fat.
Deja View - the feeling that you've seen this post before.
-
Wrong. I have a C# Windows Forms application that I executed that code in before I posted it to you. I am trying hard not to insult you ( no comments needed from you Pete :-D ), I really mean it sincerely when I suggest you need to use a beginners book. There is nothing wrong with that, I still have shelves of them at home from when I started and I still have to look things up in them almost 20 years later! :laugh: It's a never ending experience learning about development but we really need a foundation to work from.
led mike
led mike wrote:
I am trying hard not to insult you ( no comments needed from you Pete ),
Moi? Little ole moi? Would I...?
Deja View - the feeling that you've seen this post before.
-
Funky as in classy shaped icon. No insults there - just 3 MVPs chewing the fat.
Deja View - the feeling that you've seen this post before.
Which leads to another question: did/does CP ever explain what MVP stands for? it could be many things, Most Vertical Primate being one of them. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Which leads to another question: did/does CP ever explain what MVP stands for? it could be many things, Most Vertical Primate being one of them. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Which leads to another question: did/does CP ever explain what MVP stands for? it could be many things, Most Vertical Primate being one of them. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
I'd like to think it's Most Valuable Professional, but in my case it could be Madly Vocal Pessimist.
Deja View - the feeling that you've seen this post before.
-
Luc Pattyn wrote:
did/does CP ever explain what MVP stands for?
I don't know about yours but my award stands for Most Valuable Puke. I wanted Most Valuable Cookie Tosser but Chris said John Simmons already had that.
led mike
it seems to me we need another editable column in the database, so we can personalize this. And in a couple of weeks the friday quiz question: given 40 MVP names and 40 titles, who is who? :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
I'd like to think it's Most Valuable Professional, but in my case it could be Madly Vocal Pessimist.
Deja View - the feeling that you've seen this post before.
I didn't see you as a pessimist :doh:
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
so in other words you dont know thanks lol
No. He is telling you to get a book and learn.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon