2015-05-21 34 views
0

我有一個問題,也許有人幫助我。你知道在這個程序中如何做出錯誤之後如何去除圖標「error provider」消失,如果沒有更多的錯誤,但是它出現了嗎? (請原諒我的語法錯誤)如何在顯示錯誤後隱藏錯誤提供程序?

bool IsValidated = true; //will be checked on button click 
void dateTimePicker1_Validating(object sender, CancelEventArgs e) 

{ DateTimePicker datetimepicker = sender as DateTimePicker; 

if (datetimepicker.Value == null) 

{ errorProvider1.SetError(datetimepicker, "Required"); 
    IsValidated = false; 
} } 
void comboBox_Validating(object sender, CancelEventArgs e) 

{ 
    ComboBox combo = sender as ComboBox; 
    if(combo.SelectedIndex == -1) 
{ 
    errorProvider1.SetError(combo, "Required"); 
    IsValidated = false; 
}} 

void textBox_Validating(object sender, CancelEventArgs e) 
{ 
    TextBox txtbox = sender as TextBox; 
    if (txtbox.Text == "" || txtbox.Text.Length > 2) 
{ 
    errorProvider1.SetError(txtbox, "Required"); 
    IsValidated = false; 
}} 

enter image description here

+0

只有驗證成功,錯誤提供程序纔會消失。它會繼續顯示,否則 –

回答