hi im currently working on a grade book tool for teachers im a beginner im trying to just simply have the user click the button on the current page there on to open an existing window that ive already created this is the code i use

private void PROFILE_Click(object sender, EventArgs e)
        {
            this.Hide();
            ACADEMIC_PROFILE ACADEMIC_PROFILE_SCREEN = new ACADEMIC_PROFILE();
            ACADEMIC_PROFILE_SCREEN.Show();
        }
my teacher says this is a problem and i need to use:
public partial class ACADEMIC_PROFILE : Form
    {
        public VIEW_PROFILE VIEW_PROFILE_SCREEN;
        public ADD_PROFILE ADD_PROFILE_SCREEN;
        public MODIFY_PROFILE MODIFY_PROFILE_SCREEN;
        public DELETE_PROFILE DELETE_PROFILE_SCREEN;
        public WELCOME_SCREENcs WELCOME_SCREEN_SCREEN;
        
        
        
        
        
        
        
        public ACADEMIC_PROFILE()
        {
            
            InitializeComponent();
        }

        private void VIEW_PROFILE_Click(object sender, EventArgs e)
        {
            this.Hide();
            // If the panel has not created or has been disposed, create one
            if ((null == VIEW_PROFILE_SCREEN) || (VIEW_PROFILE_SCREEN.IsDisposed))
            {
                VIEW_PROFILE_SCREEN = new VIEW_PROFILE();
            }

            // Open the window
            VIEW_PROFILE_SCREEN.WindowState = FormWindowState.Maximized;
            VIEW_PROFILE_SCREEN.Show();
        }

but when i use this i get new windows instead of opening an existing one it always creates a new form can anyone help me to hide previous windows that where created without using this.hide();

Hi bmasta12 welcome.
Could you to help us, use code tags to show us your code?
Leave the upper case coding style.
Tell me what is more readable:
ACADEMIC_PROFILE ACADEMIC_PROFILE_SCREEN = new ACADEMIC_PROFILE();
AcademicProfile AcademicProfileScreen = new AcademicProfile();
and if I use that between code tags I get:

AcademicProfile AcademicProfileScreen = new AcademicProfile();

hi im currently working on a grade book tool for teachers im a beginner im trying to just simply have the user click the button on the current page there on to open an existing window that ive already created this is the code i use

[private void PROFILE_Click(object sender, EventArgs e)
{
this.Hide();
ACADEMIC_PROFILE ACADEMIC_PROFILE_SCREEN = new ACADEMIC_PROFILE();
ACADEMIC_PROFILE_SCREEN.Show();
}

my teacher says this is a problem and i need to use:

public partial class ACADEMIC_PROFILE : Form
{
public VIEW_PROFILE VIEW_PROFILE_SCREEN;
public ADD_PROFILE ADD_PROFILE_SCREEN;
public MODIFY_PROFILE MODIFY_PROFILE_SCREEN;
public DELETE_PROFILE DELETE_PROFILE_SCREEN;
public WELCOME_SCREENcs WELCOME_SCREEN_SCREEN;







public ACADEMIC_PROFILE()
{

InitializeComponent();
}

private void VIEW_PROFILE_Click(object sender, EventArgs e)
{

// If the panel has not created or has been disposed, create one
if ((null == VIEW_PROFILE_SCREEN) || (VIEW_PROFILE_SCREEN.IsDisposed))
{
VIEW_PROFILE_SCREEN = new VIEW_PROFILE();
}

// Open the window
VIEW_PROFILE_SCREEN.WindowState = FormWindowState.Maximized;
VIEW_PROFILE_SCREEN.Show();
}

but when i use this i get new windows instead of opening an existing one it always creates a new form can anyone help me to hide previous windows that where created without using
"this.hide(); "

Hi
,Instead of creating a new window the other work around is to have a singleton class for the form,make the form class( that you want to launch every time) as singleton (its a pattern,easy to implement) and return that singleton object evert time you clock.

Suppose from Form1 you want to open Form2( the same form every time,make it singleton).
void Form1_Click(....)
{
// instead of creating new,get the same instance every time)
}


hi im currently working on a grade book tool for teachers im a beginner im trying to just simply have the user click the button on the current page there on to open an existing window that ive already created this is the code i use

private void PROFILE_Click(object sender, EventArgs e)
        {
            this.Hide();
            ACADEMIC_PROFILE ACADEMIC_PROFILE_SCREEN = new ACADEMIC_PROFILE();
            ACADEMIC_PROFILE_SCREEN.Show();
        }
my teacher says this is a problem and i need to use:
public partial class ACADEMIC_PROFILE : Form
    {
        public VIEW_PROFILE VIEW_PROFILE_SCREEN;
        public ADD_PROFILE ADD_PROFILE_SCREEN;
        public MODIFY_PROFILE MODIFY_PROFILE_SCREEN;
        public DELETE_PROFILE DELETE_PROFILE_SCREEN;
        public WELCOME_SCREENcs WELCOME_SCREEN_SCREEN;
        
        
        
        
        
        
        
        public ACADEMIC_PROFILE()
        {
            
            InitializeComponent();
        }

        private void VIEW_PROFILE_Click(object sender, EventArgs e)
        {
            this.Hide();
            // If the panel has not created or has been disposed, create one
            if ((null == VIEW_PROFILE_SCREEN) || (VIEW_PROFILE_SCREEN.IsDisposed))
            {
                VIEW_PROFILE_SCREEN = new VIEW_PROFILE();
            }

            // Open the window
            VIEW_PROFILE_SCREEN.WindowState = FormWindowState.Maximized;
            VIEW_PROFILE_SCREEN.Show();
        }

but when i use this i get new windows instead of opening an existing one it always creates a new form can anyone help me to hide previous windows that where created without using this.hide();

Try this.Close()

edgias, the OP states they want to present a form they have already created. If they used that code in the form they are showing they wont be able to re-display it...and if they use it in their main form it will close that instead.

Please try to be more specific with code examples and that they are relevent to the OP's problem

Thanx for the correction

thx but how do i do what your saying.......do you mind a posting a more detailed example?

Hi
,Instead of creating a new window the other work around is to have a singleton class for the form,make the form class( that you want to launch every time) as singleton (its a pattern,easy to implement) and return that singleton object evert time you clock.

Suppose from Form1 you want to open Form2( the same form every time,make it singleton).
void Form1_Click(....)
{
// instead of creating new,get the same instance every time)
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.