我通过以下代码将数据库加载到列表框中:
using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString))
{
myDatabaseConnection.Open();
using (SqlCommand SqlCommand = new SqlCommand("Select ID, LastName from Employee", myDatabaseConnection))
{
SqlDataReader dr = SqlCommand.ExecuteReader();
while (dr.Read())
{
listBox1.Items.Add((string)dr["LastName"] + " " + dr["ID"]);
}
}
}
结果:
如何在列表框中对齐这样的数据?