如何重新加載或刷新Windows窗體到原始狀態?我已經使用this.Refresh();, this.Invalidate();, form.Refresh(),form.Invalidate()如何重新加載或刷新Windows窗體到原始狀態?
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!");
}
}
}
我只是想要重新加載的形式進入原始狀態一旦數據正確保存或更新。
什麼樣的形式是你上面的代碼?它是一個UserInfoForm?因爲如果它是保持主窗體可見,則創建一個新的UserInfoForm而不顯示它並嘗試刷新它。 –
是的,即時通訊保持主窗體可見,當我添加數據,並且當它成功保存時,主窗體將被重新加載或將被刷新到其原始狀態..它就像窗體是新鮮加載。 –