WinForm Panel 背景问题!!!!在线等!!! 妈呀,who can help me !! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用了4楼的方法,还是不行!!!让它显示在最前顶层时,panel能显示,但是没背景图 //四个队的分数 Mark pOne=new Mark(); Mark pTwo=new Mark(); Mark pThree=new Mark(); Mark pFour=new Mark(); private void MainBody_Load(object sender, System.EventArgs e) { this.palTwo.Visible=false;//让第二个面板隐藏 this.palThree.Visible=false;//让第三个面板隐藏 this.palOne.Dock=DockStyle.Fill;//让第一个面板全屏 this.MarkReadLine();//读取Mark.xrl中的分数 //将分数显示在lab中 this.labOne.Text=pOne..ToString(); this.labTwo.Text=pTwo..ToString(); this.labThree.Text=pThree..ToString(); this.labFour.Text=pFour..ToString(); this.isBtnEnabled(false);//在未进入比赛前,让加减分的按钮不可用 } private void isBtnEnabled(bool flag)//在未进入比赛前,让加减分的按钮 可/不可 用 { this.btnOneAdd.Enabled=flag; this.btnOneAec.Enabled=flag; this.btnTwoAdd.Enabled=flag; this.btnTwoAec.Enabled=flag; this.btnThreeAdd.Enabled=flag; this.btnThreeAec.Enabled=flag; this.btnFourAdd.Enabled=flag; this.btnFourAec.Enabled=flag; } private void palOne_DoubleClick(object sender, System.EventArgs e) { this.palOne.Visible=false;//让第一个面板隐藏 this.palTwo.Visible=true;//让第二个面板显示 this.palTwo.Dock=DockStyle.Fill;//让第二个面板全屏 this.isBtnEnabled(true);//让加减分的按钮可用 } private void ZeroTs(string band) { MessageBox.Show(band+"队已无分数可减","提示"); } private void MarkReadLine()//读取Mark.xrl文件中的分数 { if(!File.Exists(Application.StartupPath+@"\Mark.xrl"))//如果没有分数文件,则初始化分数,返回 return; FileStream fs = new FileStream("Mark.xrl",FileMode.Open,FileAccess.Read); //读出txt文件,且设置为只读模式 StreamReader file = new StreamReader(fs,Encoding.GetEncoding("gb2312"));//将读出的数据转换为中文 this.pOne.=int.Parse(file.ReadLine()); this.pTwo.=int.Parse(file.ReadLine()); this.pThree.=int.Parse(file.ReadLine()); this.pFour.=int.Parse(file.ReadLine()); } private void MarkWrite()//将分数写入Mark.xrl文件中 { StreamWriter sw = new StreamWriter("Mark.xrl"); sw.Write(this.pOne..ToString()+"\r\n"); sw.Write(this.pTwo..ToString()+"\r\n"); sw.Write(this.pThree..ToString()+"\r\n"); sw.Write(this.pFour..ToString()); sw.Close(); } int _vis=1;//用来在屏幕上显示第几道题的计时器 int _title=1;//每次点击“下一题”时会递增,用来计算第几道题的计时器 private string _key=""; private string subject=Application.StartupPath+@"\Subject\第一环节\个人必答题.txt";//题库 private void btnNext_Click(object sender, System.EventArgs e) { this.MediaSound.URL="Sound\\出题.wav";//发出出题声 this.tmeTime.Enabled=false;//计时器暂停 this._time=_sbTime;//20秒时间复位 this.labTime.Text=this._time.ToString();//显示复位时间 this.btnTime.Text="开始计时";//按钮变化 this.labTime.ForeColor=white;//计时器颜色变白 //将答案的lab复位,因为显示正确答案后lab已改变 this.labA.ForeColor=Color.Black; this.labA.Font=fontly; this.labB.ForeColor=Color.Black; this.labB.Font=fontly; this.labC.ForeColor=Color.Black; this.labC.Font=fontly; this.labD.ForeColor=Color.Black; this.labD.Font=fontly; if(!File.Exists(this.subject)) { MessageBox.Show("找不到题库","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } _vis=1; FileStream fs = new FileStream(this.subject,FileMode.Open,FileAccess.Read); //读出txt文件,且设置为只读模式 StreamReader file = new StreamReader(fs,Encoding.GetEncoding("gb2312"));//将读出的数据转换为中文 while(file.Peek()!=-1) { file.ReadLine();//读出第一条为空题 this.labSub.Text=file.ReadLine();//读出第二句赋给 题目 this.labA.Text=file.ReadLine();//读出第三句赋给 选项A this.labB.Text=file.ReadLine();//读出第四句赋给 选项B this.labC.Text=file.ReadLine();//读出第五句赋给 选项C this.labD.Text=file.ReadLine();//读出第六句赋给 选项D this._key=file.ReadLine(); if(_vis==_title)//如果读出的数据为当前的题目数,那么在屏幕显示后跳出读取 { break; } _vis++; } _title++; file.Close();//关闭流 } private static int _sbTime=20;//设置答题倒计时时间 private void btnTime_Click(object sender, System.EventArgs e) { if(this.btnTime.Text.Equals("开始计时")) { this.tmeTime.Enabled=true;//开启计时 this._time=_sbTime;//将时间设置为设定时间 this.btnTime.Text="暂停"; } else { this.tmeTime.Enabled=false;//暂停计时 this.btnTime.Text="开始计时"; } } private int _time=_sbTime; Color red=Color.Red; Color white=Color.White; private void tmeTime_Tick(object sender, System.EventArgs e) { if(_time<=-1) { this.MediaSound.URL=Application.StartupPath+@"\Sound\时间到.wav";//时间到则用声音提示 this.tmeTime.Enabled=false; this._time=_sbTime; this.btnTime.Text="开始计时"; } else { if(_time<=10)//时间小于10秒则用声音提示 { this.labTime.ForeColor=red; this.MediaSound.URL=Application.StartupPath+@"\Sound\最后10秒时间.WAV"; } else { this.labTime.ForeColor=white; } this.labTime.Text=_time.ToString(); this._time--; } } private void menuItem2_Click(object sender, System.EventArgs e)//这里是让panel显示的方法 { this.menuItem2.Checked=true; this.palTwo.Visible=false; this.palThree.Visible=true; this.palThree.Dock=DockStyle.Fill; this.palThree.BringToFront(); } private void menuItem11_Click(object sender, System.EventArgs e) { MessageBox.Show("本程序由 (汕头星河)北大青鸟学生会 学习部 出品","关于",MessageBoxButtons.OK,MessageBoxIcon.Asterisk); } Font fontly=new Font("黑体",26);//原始字体 Font font=new Font("黑体",30);//正确答案字体 private void btnkey_Click(object sender, System.EventArgs e)//判断答案 { if(this._key.Equals("A")) { this.labA.ForeColor=this.red; this.labA.Font=font; } if(this._key.Equals("B")) { this.labB.ForeColor=this.red; this.labB.Font=font; } if(this._key.Equals("C")) { this.labC.ForeColor=this.red; this.labC.Font=font; } if(this._key.Equals("D")) { this.labD.ForeColor=this.red; this.labD.Font=font; } } } 不要设Visible,如果你的几个Panel都是一样大小,一样位置的,不要设置Dock属性和Visible属性,用BrintToFront来显示。 dgv根据前一列数据添加图片 C#winform怎么读取数据库信息显示出来 再请教个问题 object 怎么转成 一个byte [] c# webBrowser问题 C#的app.path c#中怎样用foreach计算一个字符串的长度??? iis无法下载exe?? 我说我的兄弟姐妹们啊,快来帮帮忙啊。小弟我急死了。 在C#中,怎样调用也可以说是直接弹出 OutLook 发信窗口,并自动添加一个附件。 请教这个c#winform程序该如何写,急啊! 怎样取得DataGrid选中的行的每项的值 请教:读BIN文件然后分段发至串口的问题 switch case问题
Mark pOne=new Mark();
Mark pTwo=new Mark();
Mark pThree=new Mark();
Mark pFour=new Mark(); private void MainBody_Load(object sender, System.EventArgs e)
{
this.palTwo.Visible=false;//让第二个面板隐藏
this.palThree.Visible=false;//让第三个面板隐藏
this.palOne.Dock=DockStyle.Fill;//让第一个面板全屏 this.MarkReadLine();//读取Mark.xrl中的分数 //将分数显示在lab中
this.labOne.Text=pOne..ToString();
this.labTwo.Text=pTwo..ToString();
this.labThree.Text=pThree..ToString();
this.labFour.Text=pFour..ToString(); this.isBtnEnabled(false);//在未进入比赛前,让加减分的按钮不可用
} private void isBtnEnabled(bool flag)//在未进入比赛前,让加减分的按钮 可/不可 用
{
this.btnOneAdd.Enabled=flag;
this.btnOneAec.Enabled=flag;
this.btnTwoAdd.Enabled=flag;
this.btnTwoAec.Enabled=flag;
this.btnThreeAdd.Enabled=flag;
this.btnThreeAec.Enabled=flag;
this.btnFourAdd.Enabled=flag;
this.btnFourAec.Enabled=flag;
} private void palOne_DoubleClick(object sender, System.EventArgs e)
{
this.palOne.Visible=false;//让第一个面板隐藏
this.palTwo.Visible=true;//让第二个面板显示
this.palTwo.Dock=DockStyle.Fill;//让第二个面板全屏
this.isBtnEnabled(true);//让加减分的按钮可用
}
private void ZeroTs(string band)
{
MessageBox.Show(band+"队已无分数可减","提示");
} private void MarkReadLine()//读取Mark.xrl文件中的分数
{
if(!File.Exists(Application.StartupPath+@"\Mark.xrl"))//如果没有分数文件,则初始化分数,返回
return;
FileStream fs = new FileStream("Mark.xrl",FileMode.Open,FileAccess.Read); //读出txt文件,且设置为只读模式
StreamReader file = new StreamReader(fs,Encoding.GetEncoding("gb2312"));//将读出的数据转换为中文
this.pOne.=int.Parse(file.ReadLine());
this.pTwo.=int.Parse(file.ReadLine());
this.pThree.=int.Parse(file.ReadLine());
this.pFour.=int.Parse(file.ReadLine());
} private void MarkWrite()//将分数写入Mark.xrl文件中
{
StreamWriter sw = new StreamWriter("Mark.xrl");
sw.Write(this.pOne..ToString()+"\r\n");
sw.Write(this.pTwo..ToString()+"\r\n");
sw.Write(this.pThree..ToString()+"\r\n");
sw.Write(this.pFour..ToString());
sw.Close();
} int _vis=1;//用来在屏幕上显示第几道题的计时器
int _title=1;//每次点击“下一题”时会递增,用来计算第几道题的计时器
private string _key="";
private string subject=Application.StartupPath+@"\Subject\第一环节\个人必答题.txt";//题库
private void btnNext_Click(object sender, System.EventArgs e)
{
this.MediaSound.URL="Sound\\出题.wav";//发出出题声
this.tmeTime.Enabled=false;//计时器暂停
this._time=_sbTime;//20秒时间复位
this.labTime.Text=this._time.ToString();//显示复位时间
this.btnTime.Text="开始计时";//按钮变化
this.labTime.ForeColor=white;//计时器颜色变白 //将答案的lab复位,因为显示正确答案后lab已改变
this.labA.ForeColor=Color.Black;
this.labA.Font=fontly;
this.labB.ForeColor=Color.Black;
this.labB.Font=fontly;
this.labC.ForeColor=Color.Black;
this.labC.Font=fontly;
this.labD.ForeColor=Color.Black;
this.labD.Font=fontly; if(!File.Exists(this.subject))
{
MessageBox.Show("找不到题库","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
_vis=1;
FileStream fs = new FileStream(this.subject,FileMode.Open,FileAccess.Read); //读出txt文件,且设置为只读模式
StreamReader file = new StreamReader(fs,Encoding.GetEncoding("gb2312"));//将读出的数据转换为中文
while(file.Peek()!=-1)
{
file.ReadLine();//读出第一条为空题
this.labSub.Text=file.ReadLine();//读出第二句赋给 题目
this.labA.Text=file.ReadLine();//读出第三句赋给 选项A
this.labB.Text=file.ReadLine();//读出第四句赋给 选项B
this.labC.Text=file.ReadLine();//读出第五句赋给 选项C
this.labD.Text=file.ReadLine();//读出第六句赋给 选项D
this._key=file.ReadLine();
if(_vis==_title)//如果读出的数据为当前的题目数,那么在屏幕显示后跳出读取
{
break;
}
_vis++;
}
_title++;
file.Close();//关闭流
}
private static int _sbTime=20;//设置答题倒计时时间
private void btnTime_Click(object sender, System.EventArgs e)
{
if(this.btnTime.Text.Equals("开始计时"))
{
this.tmeTime.Enabled=true;//开启计时
this._time=_sbTime;//将时间设置为设定时间
this.btnTime.Text="暂停";
}
else
{
this.tmeTime.Enabled=false;//暂停计时
this.btnTime.Text="开始计时";
}
}
private int _time=_sbTime;
Color red=Color.Red;
Color white=Color.White;
private void tmeTime_Tick(object sender, System.EventArgs e)
{
if(_time<=-1)
{
this.MediaSound.URL=Application.StartupPath+@"\Sound\时间到.wav";//时间到则用声音提示
this.tmeTime.Enabled=false;
this._time=_sbTime;
this.btnTime.Text="开始计时";
}
else
{
if(_time<=10)//时间小于10秒则用声音提示
{ this.labTime.ForeColor=red;
this.MediaSound.URL=Application.StartupPath+@"\Sound\最后10秒时间.WAV";
}
else
{
this.labTime.ForeColor=white;
}
this.labTime.Text=_time.ToString();
this._time--;
}
} private void menuItem2_Click(object sender, System.EventArgs e)//这里是让panel显示的方法
{
this.menuItem2.Checked=true; this.palTwo.Visible=false;
this.palThree.Visible=true;
this.palThree.Dock=DockStyle.Fill; this.palThree.BringToFront();
} private void menuItem11_Click(object sender, System.EventArgs e)
{
MessageBox.Show("本程序由 (汕头星河)北大青鸟学生会 学习部 出品","关于",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
}
Font fontly=new Font("黑体",26);//原始字体
Font font=new Font("黑体",30);//正确答案字体
private void btnkey_Click(object sender, System.EventArgs e)//判断答案
{
if(this._key.Equals("A"))
{
this.labA.ForeColor=this.red;
this.labA.Font=font;
}
if(this._key.Equals("B"))
{
this.labB.ForeColor=this.red;
this.labB.Font=font;
}
if(this._key.Equals("C"))
{
this.labC.ForeColor=this.red;
this.labC.Font=font;
}
if(this._key.Equals("D"))
{
this.labD.ForeColor=this.red;
this.labD.Font=font;
}
}
}