当我尝试调用 Find() 时,我不断收到此错误
public void findTxt(string text)
{
BindingSource src = new BindingSource();
src.DataSource = dataGridView1.DataSource;
src.Position = src.Find("p_Name", text); // Specified method is not supported
if (src.Position == 0 && dataGridView1.Rows[0].Cells[2].Value.ToString() == text)
{
MessageBox.Show("Item found!!");
dataGridView1.CurrentCell = dataGridView1.Rows[src.Position].Cells[2];
}
else if (src.Position == 0 && dataGridView1.Rows[0].Cells[2].Value.ToString() != text)
{
MessageBox.Show("Item not found!!");
}
else
{
MessageBox.Show("Item found!!");
dataGridView1.CurrentCell = dataGridView1.Rows[src.Position].Cells[2];
}
}
编辑:
从另一个窗体调用 findText 方法时出现该错误,但是从主窗体调用此方法不会导致此类错误。