我有一个 DataGridView,其中有多行(15 行)。我想添加一些列值并使用foreach
loop将它们存储在一个数组中。然后我想以另一种形式显示数组(带有多个字符串)。
目前我正在使用 stringBuilder 来存储字符串并显示,但它只显示其中的最后一个字符串存储。
StringBuilder listOrderStatus = new StringBuilder();
foreach (DataGridViewRow rw in grdData.Rows)
{
string _idNumber = rw.Cells[6].Value.ToString();
string _orderNo = rw.Cells[13].Value.ToString();
double _ordTotalSpace = double.Parse(rw.Cells[17].Value.ToString());
double _ordDoneSpace = double.Parse(rw.Cells[18].Value.ToString());
double _ordRmainSpace = double.Parse(rw.Cells[19].Value.ToString());
double _TotalSpace = getTotalArea();
double _DoneSpace = getDoneArea();
double _RmainSpace = getRmainArea();
if(_ordTotalSpace ! = _TotalSpace){
string value = "Invalid Order: Order number" + _orderNo + "ID No." + _idNumber;
//I want to store this string in the array
listOrderStatus.Append(value);
listOrderStatus.AppendLine();
}
else{
string value2 = "Valid Order: Order number" + _orderNo + "ID No." + _idNumber;
//I want to store this string in the array
listOrderStatus.Append(value2);
listOrderStatus.AppendLine();
}
}
string innerString = listOrderStatus.ToString();
//This a new form to display strings in simple multiline-TextBox (Never mind, this is client request :P)
var myForm = new Other.frmDisplayData();
myForm._clist = innerString;
myForm.Show();
谁能指导我。提前致谢