Cita de: Hartigan en 14 Mayo 2010, 19:27 PMEfectivamente el error me lo da ahí. Pero como hago que no esté nulo si primeramente quiero que el listBox este vacio, es decir que no haya ningun email agregado...???
Te toca mejorarlo pero puedes probar asi:
Form1:
Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mail
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
DialogResult resul = new DialogResult();
resul = f2.ShowDialog();
if (resul == DialogResult.OK && f2.mail != string.Empty)
{
listBox1.Items.Add(f2.mail);
}
}
}
}
Form2:
Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mail
{
public partial class Form2 : Form
{
public string mail;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
button1.DialogResult = DialogResult.OK;
}
private void button1_Click(object sender, EventArgs e)
{
mail = textBox1.Text;
}
}
}