我想列出所有組合框項目在一個消息框中。但我得到的是每個項目都出現在它自己的消息框中。我知道消息框需要在循環之外,但是當我這樣做時,它說變量是未分配的。任何幫助都會很棒。在一個消息框中列出所有組合框項目
私人無效displayYachtTypesToolStripMenuItem_Click(對象發件人,EventArgs的) {
string yachtTypesString;
for (int indexInteger = 0; indexInteger < typeComboBox.Items.Count; indexInteger++)
{
yachtTypesString=typeComboBox.Items[indexInteger].ToString();
MessageBox.Show(yachtTypesString);
}
}
問題是你需要assing **串yachtTypesString; **在你的情況下,空字符串**字符串yachtTypesString值=「」; **,也將努力 – Vajura 2014-11-21 07:17:30