我得到了一个名为'data'的'word'对象列表,我有一个函数可以编辑这个列表中的一个元素并刷新DataGridView,但是当我尝试从中添加一个项目并执行一个Refresh()时,它不会将其添加到网格中。
public void edit (string en, string fr, int index)
{
data[index].english = en;
data[index].french = fr;
wordGrid.Refresh();
} // Currently works
private void quickAddButton_Click(object sender, EventArgs e)
{
string fr = addFrenchText.Text;
string eng = addEnglishText.Text;
string toWrite = eng + "_" + fr;
//Adding the word in the current database
word wordToWrite = new word(toWrite);
data.Add(wordToWrite);
wordGrid.Refresh();
} //Doesn't add the occurence