日期:2014-05-18  浏览次数:20826 次

怎么取出datagridview中某一列值和textbox值进行比较,突出选中行
怎么取出datagridview中某一列值和textbox值进行比较,突出选中行。求代码???

------解决方案--------------------
获取列值,循环行?
private void Button_Click(object sender, EventArgs e)
{
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[dataGridView.CurrentCellAddress.X];
//获取选中的单元格然后。。。。。。
}
------解决方案--------------------
看错了是跳转,网络上搜索大把。
------解决方案--------------------
选中行取值比较textBox1.Text == this.dataGridView1.CurrentRow.Cells["列名"].Value.ToString();
------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach(GridViewRow rows in GridView.Rows)
{
string text =e.Row.Cell[索引].Text;
if(text.CompareTo(TextBox1.Text))
{
//值相同的话
e.Row.Cell[索引].Text = e.Row.Cell[索引].Text.Replace(this.TextQuery.Text, " <font color= 'yellow '> " + this.txtQuery.Text + " </font> ");
}

}

大体这个思路。