Gọi hàm C# | VN-Zoom | Cộng đồng Chia Sẻ Kiến Thức Công Nghệ và Phần Mềm Máy Tính

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We need money to operate the site, and almost all of it comes from our online advertising.

If possible, please support us by clicking on the advertisements.

Please add vn-z.vn to your ad blocking whitelist or disable your adblocking software.

×

Gọi hàm C#

lucmtg3000

Gà con
mình có 3 hàm như dưới sau khi bấm nút save, nếu textbox không ghi gì thì sẽ gọi hàm callabelNotBpcode() mà nó không hiển thị thông báo ae ạ xem lỗi ở đâu mà ko hiển thị đc:
public void callabelNotBpcode()
{
ClassLabel lbNoteBpcode = new ClassLabel("Please enter a valid BP Code", 100, 128);
lbNoteBpcode.ForeColor = Color.Red;
Controls.Add(lbNoteBpcode);
}

public void txtBpcode_Validating(object sender, CancelEventArgs e)
{
callabelNotBpcode();
MyTextBox txtBpcode = (MyTextBox)sender;
if (txtBpcode.Text == "Input Code" || txtBpcode.Text == "")
{
txtBpcode.BorderColor = Color.Red;
errorProvider1.SetError(txtBpcode, "");
return;
}
else
{
//To clear the validation error
this.errorProvider1.SetError(txtBpcode,"");
txtBpcode.BorderColor = Color.LightGray;
}

}

private void btnSave_Click(object sender, EventArgs e)
{
try
{
if (this.ValidateChildren())
{
//Here the form is in valid state
//Do what you need when the form is valid
}
else
{

var listOfErrors = this.errorProvider1.ContainerControl.Controls.Cast<Control>()
.Select(c => this.errorProvider1.GetError(c))
.Where(s => !string.IsNullOrEmpty(s))
.ToList();

}
}catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}
 

baoenzo

Búa Đá Đôi
Mấy cái này thì đặt debug mà xem đi bạn. Đăng code thế này khó nhìn quá
 


Top