-4
我有問題的文本框查找我有這段程序使「Starts With」方法找到它通過將三個字母放入文本框它會找到所有匹配的三個首字母。下面是我用C#我得到NullReferenceException當我在DGV列中找到名稱的文本框
代碼private void findTextBox_TextChanged(object sender, EventArgs e)
{
var bd = (BindingSource)debtDGV.DataSource;
var dt = (DataTable)bd.DataSource;
dt.DefaultView.RowFilter = string.Format(" '{0}%'", findTextBox.Text.Trim().Replace("'", "''"));
debtDGV.Refresh();
}
什麼是null?你有附加調試器嗎?在方法的第一行放置一個斷點並對其進行調試。在調試器中一行一行地去查看哪些東西是空的。 – Stuart