سلام
منظورتون رو خوب متوجه نشدم بهتر بود کد میذاشتید تا اون رو اصلاح کنیم.
فکر میکنم یه همچین چیزی میخواین:
DataSet ds = new DataSet();
SqlConnection Connection = new SqlConnection(@"Data Source=localhost\SQLEXPRESS; database=test ;integrated security=true");
SqlDataAdapter DA = new SqlDataAdapter();
DA.SelectCommand = new SqlCommand();
DA.SelectCommand.Connection = Connection;
DA.SelectCommand.CommandText = "SELECT * FROM tb1 WHERE family LIKE '%" + textBox2.Text + "%'";
DA.Fill(ds, "tb1");
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
textBox1.Text = ds.Tables[0].Rows[0][0].ToString();
textBox2.Text = ds.Tables[0].Rows[0][1].ToString();
}
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
try
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[textBox2.Text.ToString()].Value.ToString().Equals(textBox2.Text))
{
row.Selected = true;
break;
}
}
}
catch
{
}