111,092
社区成员




private void Form1_Load(object sender, EventArgs e)
{
string sqlcon = "Data Source=PC20130329;Initial Catalog=Exam;Integrated Security=True";
SqlConnection con = new SqlConnection(sqlcon);
int x = this.ClientRectangle.Width;
string sql="select * from Question";
SqlCommand command = new SqlCommand(sql,con);
con.Open();
SqlDataReader dataReader = command.ExecuteReader();
dataReader.Read();
string ss = (string)dataReader["Question"];
Label ques = new Label();
ques.Parent = panel;
ques.Font = new Font("宋体", 14);
ques.Width = x;
ques.Height = 100;
ques.AutoSize = false;
ques.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right|AnchorStyles.Bottom;
ques.Location = new Point(0, 0);
ques.BorderStyle = BorderStyle.FixedSingle;
ques.Text = ss;
Label ques0 = new Label();
ques0.Parent = panel;
ques0.Width = x;
/*//////高度
int meihang=x/20;
int a = ss.Length;
int hang =( a % meihang == 0 ? (a / meihang) : ((a / meihang)+1));
ques0.Height = hang * 20;
*//////////
ques0.AutoSize = false;
ques0.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
int y = ques.Location.Y + ques.Size.Height + 20;
ques0.Location = new Point(0,180);
ques0.BorderStyle = BorderStyle.FixedSingle;
ques0.Text = ss;
ques0.Font = new Font("宋体", 14);
dataReader.Close();
con.Close();
con.Dispose();
}