如何重新加载或刷新 Windows 窗体到原始状态?我用过 this.Refresh();,this.Invalidate();,form.Refresh(),form.Invalidate()
private void AdduserBtn_Click_1(object sender, EventArgs e)
{
UserManagement obj = new UserManagement ();
obj.CourseCategoryId = (int) CourseRegCbox.SelectedValue;
obj.IDNumber = IDNumberTbox.Text;
obj.Password = PasswordRegTbox.Text;
obj.FName = FnameRegTbox.Text;
obj.LName = LnameRegTbox.Text;
obj.Gender = GenderTbox.Text;
obj.Email = EmailRegTbox.Text;
obj.PhoneNumber = PhonenumberRegTbox.Text;
obj.Address = AddressRegTbox.Text;
if ( UserManagement != null && UserManagement.Id > 0 )
{
obj.Id = UserManagement.Id;
if ( UserManagement.UserInfo_Update (obj) > 0 )
{
MessageBox.Show ("Record Succesfully Updated!");
UserInfoForm form = new UserInfoForm ();
form.Refresh ();
}
else
{
MessageBox.Show ("An error occured!");
}
}
else
{
if ( UserManagement.UserInfo_Insert (obj) > 0 )
{
MessageBox.Show ("Record Succesfully Added!");
UserInfoForm form = new UserInfoForm ();
form.Refresh ();
}
else
{
MessageBox.Show ("An error occured!");
}
}
}
一旦数据正确保存或更新,我只想将表单重新加载到原始状态。