我正在使用此代码,但它只显示newlabelName
foreach (var type in obj.sType)
{
Label newLabelForName = new Label
{
Text = type.sName,
Font = new Font("Arial", 16),
AutoSize = false,
BackColor = Color.Red,
Width = formObject.panelDetail.Width
};
Label newLabelForPrice = new Label
{
Text = "Price : " + type.fPrice ,
Font = new Font("Arial", 16),
};
Label newLabelForQuantity = new Label
{
Text = "Quantity : " + type.sQuantity,//newLabelForName.Text + Environment.NewLine + newLabelForPrice,
Font = new Font("Arial", 16)
};
formObject.panelDetail.Controls.Add(newLabelForName);
formObject.panelDetail.Controls.Add(newLabelForPrice);
formObject.panelDetail.Controls.Add(newLabelForQuantity);
}
sType是对象中的对象数组,我使用sName,fPrice和sQuantity