我正在为学校制作一个小小的音乐节目,并且我在我的richtextbox(rtb)中遇到了问题,它一直在添加以前的所有歌曲,我不知道如何修复它而不清理我每次点击按钮都会一遍又一遍。
private void AddSongKtab()
{
SongKtab[nr] = new SongInfo();
string m_SongName;
string m_SongLocation;
ofdOpenKtab.ShowDialog();
m_SongName = ofdOpenKtab.SafeFileName;
m_SongLocation = ofdOpenKtab.FileName;
SongKtab[nr].SongName = m_SongName;
SongKtab[nr].SongLocation = m_SongLocation;
tbAddKtab.Text = "";
tbAddKtab.Text = m_SongName;
rtbExtraKtab.AppendText("added" + m_SongName + "\n");
rtbExtraKtab.AppendText("Located at " + m_SongLocation + "\n\n");
rtbSongsKtab.ScrollToCaret();
nr++;
showAllKtab();
}
private void showAllKtab()
{
int m_index;
rtbExtraKtab.Clear();
for (m_index = 0; m_index < nr; m_index++)
{
rtbSongsKtab.AppendText(SongKtab[m_index].SongName + "\n");
}
}