-1
我試圖從我的文件打印到文本框的所有真實的語句。出於某種原因,只有1行出現。我看不到錯誤或錯過了支架。只打印1行到文本框,而不是所有語句c#
我有單選按鈕,我已經分配了一個變量然後打印到正在工作的文檔。我用.toString();因爲我得到一個錯誤,無法將字符串更改爲int,當時我試圖在txtbox中顯示這個摘要。
`
//if radio button is checked write to file
if (rdoIndoor.Checked == true)
{
rdoIndoor.Text = iIndoor.ToString();
sw.WriteLine(rdoIndoor.Text);
}
else
{
rdoOutdoor.Text = iOutdoor.ToString();
sw.WriteLine(rdoOutdoor.Text);
}
//if radio button is checked write to file
if (rdoFree.Checked == true)
{
rdoFree.Text = iFree.ToString();
sw.WriteLine(rdoFree.Text);
}
else
{
rdoPriced.Text = iPriced.ToString();
sw.WriteLine(rdoPriced.Text);
}
代碼:
txtSummary.Text = "Music events were most popular this year" + Environment.NewLine;
}
else
{
txtSummary.Text = "Theatre events were most popular this year" + Environment.NewLine;
}
//find out if free or pri string line = string.Empty;
while ((line = sr.ReadLine()) != null)
{
for (int iCount = 0; iCount < sMonths.Length; iCount++)
{
//conditions
if (iCount == 2)
{
sMonths[iCount] = sr.ReadLine();
//find out which type of event was more popular within the year
if (iCountDance > iCountArt && iCountDance > iCountMusic && iCountDance > iCountTheatre)
{
txtSummary.Text = "Dance events were most popular this year" + Environment.NewLine;
}
else if (iCountArt > iCountDance && iCountArt > iCountMusic && iCountArt > iCountTheatre)
{
txtSummary.Text = "Art events were most popular this year" + Environment.NewLine;
}
else if (iCountMusic > iCountDance && iCountMusic > iCountArt && iCountMusic > iCountTheatre)
{ced events were more popular this year
if (iPriced > iFree)
{
txtSummary.Text = "Priced events were more popular this year" + Environment.NewLine;
}
else if (iFree > iPriced)
{
txtSummary.Text = "Free events were moree popular this year" + Environment.NewLine;
}
iAttendanceTotal = iAttendance * iAttendance;
txtSummary.Text = "At least " + iAttendanceTotal + " people attended events over the year" + Environment.NewLine;
}
文本框文本到文件可以嗎?但文本文本到文本框不是,是嗎? –
@LP。 Gonçalves是的,它之前是從文件到列表框,但由於for循環它只是重複循環,所以我改爲閱讀文本框,它不再起作用。 – Lorna