Hola buenas estoy haciendo un formulario en el cual quiero que al presionar un Button se abra el formulario 2 (con una animación la cual hice con un timer) y desde el formulario 2 al presionar un Button que vuelva al form1 con la misma animación del timer... (Espero y me explique bien)
el codigo del form1 es este:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class tabIngresar : Form
{
public tabIngresar()
{
InitializeComponent();
}
tabRegistro frm2 = new tabRegistro();
private void textBox1_Click(object sender, EventArgs e)
{
textUser.Clear();
picUsuario.Image = Properties.Resources.User2;
panelUser.BackColor = Color.FromArgb(78, 184, 206);
textUser.ForeColor = Color.FromArgb(78, 184, 206);
picPass.Image = Properties.Resources.Pass1;
panelPass.BackColor = Color.WhiteSmoke;
textPass.ForeColor = Color.WhiteSmoke;
}
private void textBox2_Click(object sender, EventArgs e)
{
textPass.Clear();
textPass.PasswordChar = '•';
picPass.Image = Properties.Resources.Pass2;
panelPass.BackColor = Color.FromArgb(78, 184, 206);
textPass.ForeColor = Color.FromArgb(78, 184, 206);
picUsuario.Image = Properties.Resources.User1;
panelUser.BackColor = Color.WhiteSmoke;
textUser.ForeColor = Color.WhiteSmoke;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Start();
}
//Animación
private void timer1_Tick(object sender, EventArgs e)
{
frm2.Left += 10;
if(frm2.Left >= 830)
{
timer1.Stop();
this.TopMost = false;
frm2.TopMost = true;
timer2.Start();
}
}
private void timer2_Tick(object sender, EventArgs e)
{
frm2.Left -= 10;
if(frm2.Left <= 525)
{
timer2.Stop();
}
}
private void Form1_Load(object sender, EventArgs e)
{
frm2.Show();
}
}
}
Intente hacerlo de la misma forma en el form2 pero me da este error: system.stackoverflowexception
El codigo del form 2 es este:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class tabRegistro : Form
{
public tabRegistro()
{
InitializeComponent();
}
tabIngresar frm1 = new tabIngresar();
private void textUser_Click(object sender, EventArgs e)
{
textUser.Clear();
picUsuario.Image = Properties.Resources.User2;
panelUser.BackColor = Color.FromArgb(78, 184, 206);
textUser.ForeColor = Color.FromArgb(78, 184, 206);
picPass.Image = Properties.Resources.Pass1;
panelPass.BackColor = Color.WhiteSmoke;
textPass.ForeColor = Color.WhiteSmoke;
picEmail.Image = Properties.Resources.Email1;
panelEmail.BackColor = Color.WhiteSmoke;
textEmail.ForeColor = Color.WhiteSmoke;
}
private void textPass_Click(object sender, EventArgs e)
{
textPass.Clear();
textPass.PasswordChar = '•';
picPass.Image = Properties.Resources.Pass2;
panelPass.BackColor = Color.FromArgb(78, 184, 206);
textPass.ForeColor = Color.FromArgb(78, 184, 206);
picUsuario.Image = Properties.Resources.User1;
panelUser.BackColor = Color.WhiteSmoke;
textUser.ForeColor = Color.WhiteSmoke;
picEmail.Image = Properties.Resources.Email1;
panelEmail.BackColor = Color.WhiteSmoke;
textEmail.ForeColor = Color.WhiteSmoke;
}
private void textEmail_Click_1(object sender, EventArgs e)
{
textEmail.Clear();
picEmail.Image = Properties.Resources.Email2;
panelEmail.BackColor = Color.FromArgb(78, 184, 206);
textEmail.ForeColor = Color.FromArgb(78, 184, 206);
picPass.Image = Properties.Resources.Pass1;
panelPass.BackColor = Color.WhiteSmoke;
textPass.ForeColor = Color.WhiteSmoke;
picUsuario.Image = Properties.Resources.User1;
panelUser.BackColor = Color.WhiteSmoke;
textUser.ForeColor = Color.WhiteSmoke;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
frm1.Left += 10;
if (frm1.Left >= 830)
{
timer1.Stop();
this.TopMost = false;
frm1.TopMost = true;
timer2.Start();
}
}
private void timer2_Tick(object sender, EventArgs e)
{
frm1.Left -= 10;
if (frm1.Left <= 525)
{
timer2.Stop();
}
}
}
}
Alguien me ayuda? soy nuevo en esto xd...
Mucha Gracias de Antemano