Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1") If e.Form.ExistControl("Button1") Dim qrxg As WinForm.Button = e.Form.Controls("Button1") If tab.SelectedIndex = 1 Then If qrxg.Visible = True Then MessageBox.Show("请先确认修改后再离开界面!","错误提示", MessageBoxButtons.OK ,MessageBoxIcon.Information) e.Cancel = True End If End If End If