public void Pretable(DataGridView dataGridView1, List<string> predat, int count)
{
for (int i = 0; i < 9; i++)
{
dataGridView1.Columns.Add(new DataGridViewTextBoxColumn());
}
string[] fst = { "点位", "B1", "L1", "A1", "S", "点位", "B2", "L2", "A2" };
for (int j = 0; j < 9; j++)
{
dataGridView1.Columns[j].HeaderText = fst[j];
}
for (int i = 0; i < ((count - 2) / 4); i++)
{
dataGridView1.Rows.Add();
}
for (int i = 0; i < ((count - 2) / 4); i++)
{
dataGridView1.Rows[i].Cells[0].Value = "P" + (2 * i + 1);
dataGridView1.Rows[i].Cells[1].Value = pe.trantxttams(double.Parse(predat[2 + i * 4]));
dataGridView1.Rows[i].Cells[2].Value = pe.trantxttams(double.Parse(predat[3 + i * 4]));
dataGridView1.Rows[i].Cells[3].Value = pe.trantxttams(double.Parse(predat[4 + i * 4]));
dataGridView1.Rows[i].Cells[4].Value = predat[5 + i * 4];
}
}
c#表格显示dataGridView(自用)
于 2024-05-31 16:23:19 首次发布