Witam serdecznie.
Piszę sobie mały programik, w którym użytkownik na początku podaje swoje imię w kontrolce, a po kliknięciu Zapisz kontrolka powinna zniknąć oraz Form1 powinien mieć ustawioną wartość Enabled = true; Problem w tym, że kontrolka nie chce zniknąć, a Form1 nie chce się odblokować. Co robię nie tak? o_O
Kontrolka:
public partial class dane : UserControl
{
public event EventHandler Zapisz;
public dane()
{
InitializeComponent();
button1.Click += button1_Click;
}
void button1_Click(object sender, EventArgs e)
{
foreach (var item in this.Parent.Controls)
{
if (item is dane && !item.Equals(this))
{
(item as dane).Hide();
}
}
OnZapisz();
}
protected virtual void OnZapisz()
{
if (Zapisz != null)
{
Zapisz(this, new EventArgs());
}
}
}
Form1:
private void dane_Zapisz(object sender, EventArgs e)
{
(sender as Control).Hide();
}