PDA

View Full Version : سوال: ارور هنگام Visible کردن دیتاگریدویو



jafarpalideh
چهارشنبه 28 آذر 1397, 09:57 صبح
با سلام به همه.
یه فرم دارم مثل شکل پایین.

149456
دوتا تکست باکسه که یکی Readonly هست و یه دونه دیتاگرید که اولش Hide هست و کد زیر رو تویه رویداد TextChange اولی نوشتم .



private void txtFullName_TextChanged(object sender, EventArgs e)
{
if (txtFullName.Text == "")
{
dataGridView2.Visible = false;
}
else if (txtFullName.Text != "")
{
txtFullName2.ResetText();
dataGridView2.Visible = true;
bindSarbar();
}
}


متدم هم اینه :



private void bindSarbar()
{
dataGridView2.AutoGenerateColumns = false;
string Found = "select * From Vw_PersonOrCompany where Fullname LIKE '%" + txtFullName.Text.Trim() + "%'";
DataTable dtFound = new DataTable();
dtFound = Function.DoQuery(Found);
dataGridView2.DataSource = dtFound;
int height = dtFound.Rows.Count;
if (height > 100)
{
dataGridView2.Height = 300;
}
else
{
dataGridView2.Height = 150;
}
}


ولی موقع تایپ و دقیقا موقع Visible شدن دیتاگریدویو این ارور رو میگریم .



System.InvalidOperationException: 'This operation cannot be performed while an auto-filled column is being resized.'




مشکل کدم کجاست ؟