界面中只能显示有选中的radiobutton,移动滚动条时,会自动回到最后一个radiobutton选中的界面,无法查看奇遇内容,什么情况,是控件聚焦的问题吗?我也没有任何聚焦的操作啊!!
4 个解决方案
#1
你代码有特殊处理吧
#2
不知道,
不过为什么不设计成一个界面呢,做完一题按下一题时,就调把下一题的题目和答案显示出来,
不过为什么不设计成一个界面呢,做完一题按下一题时,就调把下一题的题目和答案显示出来,
#3
是一个考试系统,一次只能看一题不太好。
#4
什么特殊处理?
Label xuanzeti = new Label();
xuanzeti.Parent = pn;
xuanzeti.Text = "选择题(20×5')";
xuanzeti.Location = new System.Drawing.Point(10, 10);
xuanzeti.Font = new Font("黑体", 12);
xuanzeti.AutoSize = true;
xuanzeti.Visible = true;
pn.Visible = true;
sql = string.Format("select OptTikuNum,OptQuestion,OptA,OptB,OptC,OptD from OptTiku where IsNot='True' order by newId()");
command.CommandText = sql;
DBHelper.connection.Open();
SqlDataReader dataReader = command.ExecuteReader();
if (!dataReader.HasRows)
{
MessageBox.Show("抱歉,未完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
int i = 0;
while (i < 20 && dataReader.Read())
{
optnum[i] = (int)dataReader["OptTikuNum"];
question = (string)dataReader["OptQuestion"];
optA = (string)dataReader["OptA"];
optB = (string)dataReader["OptB"];
optC = (string)dataReader["OptC"];
optD = (string)dataReader["OptD"];
//题目
ques[i] = new Label();
ques[i].Parent = pn;
ques[i].Text = "第" + (i + 1) + "题、" + question;
ques[i].Font = new Font("宋体", 10);
ques[i].Location = new System.Drawing.Point(x, y); ;
ques[i].Visible = true;
ques[i].AutoSize = true;
A[i] = new RadioButton();
B[i] = new RadioButton();
C[i] = new RadioButton();
D[i] = new RadioButton();
ABDC[i] = new Panel();
ABDC[i].Parent = pn;
ABDC[i].AutoSize = true;
A[i].Parent = ABDC[i];
B[i].Parent = ABDC[i];
C[i].Parent = ABDC[i];
D[i].Parent = ABDC[i];
//A
y = ques[i].Location.Y + ques[i].Size.Height + 5;
A[i].Text = "A、" + optA;
A[i].Font = new Font("宋体", 10);
A[i].Location = new System.Drawing.Point(22, y); ;
A[i].Visible = true;
A[i].AutoSize = true;
//B
y = A[i].Location.Y + A[i].Size.Height + 5;
B[i].Text = "B、" + optB;
B[i].Font = new Font("宋体", 10);
B[i].Location = new System.Drawing.Point(22, y); ;
B[i].Visible = true;
B[i].AutoSize = true;
//C
y = B[i].Location.Y + B[i].Size.Height + 5;
C[i].Text = "C、" + optC;
C[i].Font = new Font("宋体", 10);
C[i].Location = new System.Drawing.Point(22, y); ;
C[i].Visible = true;
C[i].AutoSize = true;
//D
y = C[i].Location.Y + C[i].Size.Height + 5;
D[i].Text = "D、" + optD;
D[i].Font = new Font("宋体", 10);
D[i].Location = new System.Drawing.Point(22, y); ;
D[i].Visible = true;
D[i].AutoSize = true;
y = D[i].Location.Y + D[i].Size.Height + 12;
++i;
}
}
dataReader.Close();
DBHelper.connection.Close();
#1
你代码有特殊处理吧
#2
不知道,
不过为什么不设计成一个界面呢,做完一题按下一题时,就调把下一题的题目和答案显示出来,
不过为什么不设计成一个界面呢,做完一题按下一题时,就调把下一题的题目和答案显示出来,
#3
是一个考试系统,一次只能看一题不太好。
#4
什么特殊处理?
Label xuanzeti = new Label();
xuanzeti.Parent = pn;
xuanzeti.Text = "选择题(20×5')";
xuanzeti.Location = new System.Drawing.Point(10, 10);
xuanzeti.Font = new Font("黑体", 12);
xuanzeti.AutoSize = true;
xuanzeti.Visible = true;
pn.Visible = true;
sql = string.Format("select OptTikuNum,OptQuestion,OptA,OptB,OptC,OptD from OptTiku where IsNot='True' order by newId()");
command.CommandText = sql;
DBHelper.connection.Open();
SqlDataReader dataReader = command.ExecuteReader();
if (!dataReader.HasRows)
{
MessageBox.Show("抱歉,未完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
int i = 0;
while (i < 20 && dataReader.Read())
{
optnum[i] = (int)dataReader["OptTikuNum"];
question = (string)dataReader["OptQuestion"];
optA = (string)dataReader["OptA"];
optB = (string)dataReader["OptB"];
optC = (string)dataReader["OptC"];
optD = (string)dataReader["OptD"];
//题目
ques[i] = new Label();
ques[i].Parent = pn;
ques[i].Text = "第" + (i + 1) + "题、" + question;
ques[i].Font = new Font("宋体", 10);
ques[i].Location = new System.Drawing.Point(x, y); ;
ques[i].Visible = true;
ques[i].AutoSize = true;
A[i] = new RadioButton();
B[i] = new RadioButton();
C[i] = new RadioButton();
D[i] = new RadioButton();
ABDC[i] = new Panel();
ABDC[i].Parent = pn;
ABDC[i].AutoSize = true;
A[i].Parent = ABDC[i];
B[i].Parent = ABDC[i];
C[i].Parent = ABDC[i];
D[i].Parent = ABDC[i];
//A
y = ques[i].Location.Y + ques[i].Size.Height + 5;
A[i].Text = "A、" + optA;
A[i].Font = new Font("宋体", 10);
A[i].Location = new System.Drawing.Point(22, y); ;
A[i].Visible = true;
A[i].AutoSize = true;
//B
y = A[i].Location.Y + A[i].Size.Height + 5;
B[i].Text = "B、" + optB;
B[i].Font = new Font("宋体", 10);
B[i].Location = new System.Drawing.Point(22, y); ;
B[i].Visible = true;
B[i].AutoSize = true;
//C
y = B[i].Location.Y + B[i].Size.Height + 5;
C[i].Text = "C、" + optC;
C[i].Font = new Font("宋体", 10);
C[i].Location = new System.Drawing.Point(22, y); ;
C[i].Visible = true;
C[i].AutoSize = true;
//D
y = C[i].Location.Y + C[i].Size.Height + 5;
D[i].Text = "D、" + optD;
D[i].Font = new Font("宋体", 10);
D[i].Location = new System.Drawing.Point(22, y); ;
D[i].Visible = true;
D[i].AutoSize = true;
y = D[i].Location.Y + D[i].Size.Height + 12;
++i;
}
}
dataReader.Close();
DBHelper.connection.Close();