0
對於如何用單圈數作爲行和單圈時間填充我的datagridview作爲列,我無能爲力。我會非常感謝任何建議。這裏是我的比賽圈數和時間陣列的代碼:用雙精度數組填充datagridview(行)
public double[] LapTimes_Method(int NumLaps, double LapTime)
{
double[] raceLapArray = new double[NumLaps];
for (int x = 0; x < NumLaps; x++)
{
Random Random_Numbers = new Random(DateTime.Now.Millisecond);
double RandomLapNumber;
RandomLapNumber = Random_Numbers.Next(98, 102)/100;
double RandomTime;
RandomTime = LapTime * RandomLapNumber;
raceLapArray[x] = RandomTime;
}
return raceLapArray;
}
我爲這種混亂道歉。這裏就是我試圖用不同的圈數來填充的DataGridView行的代碼:
private void dgd_Simulation_Results_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
Simulation_Calculations Name2;
Name2 = new Simulation_Calculations();
int input;
bool isInt = int.TryParse(text_S_NumLaps.Text, out input);
double input2;
bool isDouble = double.TryParse(text_S_Lap_Time.Text, out input2);
double[] raceLapArray;
if (isInt == true && isDouble == true)
{
raceLapArray = Name2.LapTimes_Method(input, input2);
dgd_Simulation_Results.Rows[e.RowIndex].Cells[input].Value = "Lap" + input;
}
DataGridColumnStyle.Equals(input, input2);
}
代碼沒有問題。我不知道如何用存儲的值填充我的datagridview。以Numlaps爲行,LapTime爲列。 – Jcannon99
填充datagridview的代碼是什麼樣的?你試過什麼了?你知道如何填充這種類型的控件嗎?您嘗試顯示哪種類型的數據。 **你問的問題是什麼?** – gunr2171
我試圖像列表框一樣填充dgd,但這顯然不起作用:'dgd_Simulation_Results.NewRowIndex.Equals(「Lap」+(x + 1)); dgd_Simulation_Results.Columns.Add(raceLapArray [x]);' 。我試圖顯示字符串「LapNumber」作爲行,並在每個相應的「LapNumber」旁邊有一個「Laptime」。 – Jcannon99