c# listbox 显示问题,怎么整齐显示。
stringconText="DataSource=LENOVO-PC\\LENOVOSQLEXPRESS;InitialCatalog=Score;UserId=sa;...
string conText = "Data Source=LENOVO-PC\\LENOVOSQLEXPRESS;Initial Catalog=Score;User Id=sa;Password=123456;";SqlConnection sqlCon = new SqlConnection();sqlCon.ConnectionString = conText;sqlCon.Open();string interst;interst = "select name as '姓名',score as '得分',Crossing as '关卡' from scores order by score desc ";SqlCommand command = new SqlCommand();command.CommandText = interst;command.Connection = sqlCon;SqlDataReader dr = command.ExecuteReader();while (dr.Read()){listBox1.Items.Add(dr[0].ToString() + " " + dr[1].ToString() + " " + dr[2].ToString());}dr.Close(); 一个是数据库表上内容。一个是在listbox里面显示的截图。由于刚学不久,谁帮我改下代码。 让数据在listbox里面一竖排 一竖排显示的整齐;
展开
4个回答
2014-01-17
展开全部
画表格线啊,代码如:
Linelist.GridLines = true; //显示表格线
Linelist.View = View.Details;//显示表格细节
Linelist.FullRowSelect = true;//是否可以选择行
Linelist.Columns.Add("姓名", 60);
Linelist.Columns.Add("成绩", 60);
Linelist.Columns.Add("关卡", 100);
解释:Linelist(listbox),Add为 添加列
望采纳
Linelist.GridLines = true; //显示表格线
Linelist.View = View.Details;//显示表格细节
Linelist.FullRowSelect = true;//是否可以选择行
Linelist.Columns.Add("姓名", 60);
Linelist.Columns.Add("成绩", 60);
Linelist.Columns.Add("关卡", 100);
解释:Linelist(listbox),Add为 添加列
望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询