我在单击按钮时打开另一个表单,但在执行此操作时无法决定如何关闭当前表单。这是代码:
private void nextSportButton_Click(object sender, EventArgs e)
{
for (int i = 0; i < Form1.sportsAdded; i++)
{
if (Form1.sportOpened == i)
{
Form1.IDNumber = Form1.sportIDArray[i];
OutputForm OutputForm = new OutputForm();
OutputForm.ShowDialog();
}
this.Close();
}
}
答案 0 :(得分:2)
调用OutputForm.ShowDialog()等待,直到OutputForm关闭,然后才返回执行更多代码。您想要使用OutputForm.Show()。
注意:如果“this”是您的应用程序的主要表单(显示的第一个表单),关闭“this”将终止整个应用程序。
答案 1 :(得分:0)
首先隐藏当前表单,打开新表单后不要关闭,
this.Hide();
Form1.IDNumber = Form1.sportIDArray[i];
OutputForm OutputForm = new OutputForm();
OutputForm.ShowDialog();
答案 2 :(得分:0)
使用@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 300;
src: local('Lato Light'), local('Lato-Light'), url(http://fonts.gstatic.com/s/lato/v11/EsvMC5un3kjyUhB9ZEPPwg.woff2) format('woff2');
}
section,body{
margin: 0;
padding: 0 0 0 0;
border:0;
vertical-align: baseline;
font-size: 100%;
font: inherit;
}
.content-fluid {
margin-right: auto;
margin-left: auto;
padding-left: 0px;
padding-right: 0px
}
body{
height: 100%;
}
body {
font-size:62.5%;
font-family: 'Lato', sans-serif;
color:#FFF;
}
.panel {
height:100vh;
border-bottom:1px solid #666;
}
.welcome{
background: url("../img/background_opt.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.btn-color-shihab{
background: -webkit-linear-gradient(left, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -o-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -moz-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: linear-gradient(to right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
text-align: center;
}
.btn-color-home{
background: -webkit-linear-gradient(left, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -o-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -moz-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: linear-gradient(to right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
text-align: center;
}
.btn-color-resume{
background: -webkit-linear-gradient(left, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -o-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -moz-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: linear-gradient(to right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
text-align: center;
}
.btn-color-skill{
background: -webkit-linear-gradient(left, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -o-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -moz-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: linear-gradient(to right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
text-align: center;
}
.btn-color-portfolio{
background: -webkit-linear-gradient(left, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -o-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -moz-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: linear-gradient(to right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
text-align: center;
}
.btn-color-contact{
background: -webkit-linear-gradient(left, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -o-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: -moz-linear-gradient(right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
background: linear-gradient(to right, rgba(48,48,48,1), rgba(0,0,0,.5),rgba(48,48,48,1));
text-align: center;
}
.home{
background: url("../img/background_opt.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.resume{
background: url("../img/background_opt.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.skill{
background: url("../img/background_opt.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.wrapper{
background: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,.5),rgba(0,0,0,0));
background: -o-linear-gradient(right, rgba(0,0,0,0), rgba(0,0,0,.5),rgba(0,0,0,0));
background: -moz-linear-gradient(right, rgba(0,0,0,0), rgba(0,0,0,.5),rgba(0,0,0,0));
background: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,.5),rgba(0,0,0,0));
}
.header_overwrite{
display: block;
padding-bottom:5em;
margin:20% 0 0 28%;
}
@media(max-width:1200px){
.header_overwrite{
display: block;
padding-bottom:5em;
margin:25% 0 0 23%;
}
}
@media(max-width:900px){
.header_overwrite{
display: block;
padding-bottom:5em;
margin:25% 0 0 14%;
}
}
@media(max-width:700px){
.header_overwrite{
display: block;
padding-bottom:5em;
margin:40% 0 0 10%;
}
}
@media(max-width:500px){
.header_overwrite{
display: block;
padding-bottom:5em;
margin:50% 0 0 5%;
}
}
@media(min-width:200px){
.h1_style {
font-size:2em;
font-family: 'Lato', sans-serif;
color:#FFF;
padding:0em 0 0 1em;
}
}
@media(min-width:380px){
.h1_style {
font-size:2.5em;
font-family: 'Lato', sans-serif;
color:#FFF;
padding:0em 0 0 1em;
}
}
@media(min-width:550px){
.h1_style {
font-size:3.5em;
font-family: 'Lato', sans-serif;
color:#FFF;
padding:0em 0 0 1em;
}
}
@media(min-width:680px){
.h1_style {
font-size:4em;
font-family: 'Lato', sans-serif;
color:#FFF;
padding:0em 0 0 1em;
}
}
.h1_style {
font-size:4em;
font-family: 'Lato', sans-serif;
color:#FFF;
padding:0em 0 0 1em;
}
a:link,
a:visited {
color:#FFF;
text-decoration:none;
}
.scroll {
position:relative;
font-size:1.5em;
margin:3em 0 0 30.0em;
display:inline-block;
}
@media(max-width:1300px){
.scroll {
position:relative;
font-size:1.5em;
margin:3em 0 0 28.0em;
display:inline-block;
}
}
@media(max-width:1190px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 23.0em;
display:inline-block;
}
}
@media(max-width:1050px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 20.0em;
display:inline-block;
}
}
@media(max-width:890px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 16.0em;
display:inline-block;
}
}
@media(max-width:730px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 13.0em;
display:inline-block;
}
}
@media(max-width:670px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 10.0em;
display:inline-block;
}
}
@media(max-width:550px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 6.0em;
display:inline-block;
}
}
@media(max-width:410px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 4.0em;
display:inline-block;
}
}
@media(max-width:350px){
.scroll {
position:relative;
font-size:1.5em;
margin:2em 0 0 3.0em;
display:inline-block;
}
}
.scroll:after{
content: '';
height: 50px;
width:50px;
position: absolute;
top:20px;
right:0;
bottom:0;
left:60px;
border-right: 2px solid #FFF;
border-bottom: 2px solid #FFF;
-webkit-transform:rotate(45deg);
transform:rotate(45deg);
-webkit-animation:3s arrow infinite ;
animation:3s arrow infinite ;
}
@webkit-keyframes arrow{
0%,100%{
top:20px;
}
50%{
top:40px;
}
}
@keyframes arrow{
0%,100%{
top:20px;
}
50%{
top:40px;
}
}
.slide{
background-size: cover;
}
#slide1{
background: url("../img/bg2.jpg");
padding: 6% 0 0 0;
}
#slide2{
background: url("../img/bg5.jpg");
padding: 6% 0 0 0;
}
#slide3{
background: url("../img/bg2.jpg");
padding: 6% 0 0 0;
}
#slide4{
background: url("../img/bg5.jpg");
padding: 6% 0 0 0;
}
代替this.Hide();
,在this.Close();
循环中使用this.Close();
会引发异常。