Hej,
Mam taką apkę:
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 ep
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0)
{
errorProvider1.SetError(textBox1, "nic nie wpisano");
}
if (textBox2.Text.Length == 0)
{
errorProvider1.SetError(textBox2, "nic nie wpisano!");
}
}
private void button2_Click(object sender, EventArgs e)
{
//TO NIE DZIAŁA :-(
foreach (ErrorProvider tb in this.Controls.OfType<ErrorProvider>())
{
tb.Dispose();
}
}
}
}
Jak widać, bo nie wpisaniu niczego w textboxy i kliknięciu w button1, pojawiają mi się 2 ErrorProvidery.
Chciałbym teraz po kliknięciu 2giego buttona je skasować, lecz niestety kod który dałem nie działa..
Jak to powininem zrobić?