如何在datagridview中找到excel! [英] how do excel find in datagridview !?
本文介绍了如何在datagridview中找到excel!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi guy's
i使用此代码:
hi guy's
i used this code :
private void textBox1_TextChanged(object sender, EventArgs e)
{
// DataGridViewRow row2 =
//(from DataGridViewRow r in dataGridView1.Rows
// where r.Cells["InvoiceId"].Value.ToString().Equals(textBox1.Text)
// select r).FirstOrDefault();
// if (row2 != null)
// row2.Selected = true;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["InvoiceId"].Value == null)
{
continue;
}
if (row.Cells["InvoiceId"].Value.ToString().Trim() == textBox1.Text)
{
dataGridView1.CurrentCell = row.Cells["InvoiceId"];
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows[row.Index].Index;
return;
}
}
}
在datagridview中搜索以查找并选择行! (没有过滤器)
对接,当数据网格在行中有重复值--->错误!
如果每次点击Btn_find,如何将按钮放到下一行?
(查找类似的Excel)
谢谢
to search in datagridview to find and select row ! (no filter)
butt, when datagrid have Repetitive value in row's ---> ERROR !
How do I put a button to the next row with every click to Btn_find ?
(Find similar Excel)
thanks
推荐答案
错误可以!
如何找到下一行:
error be OK !
how find next row :
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "Find Next";
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["ProductId"].Value == null)
{
continue;
}
if (row.Cells["ProductId"].Value.ToString().Trim() == textBox1.Text)
{
dataGridView1.CurrentCell = row.Cells["ProductId"];
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows[row.Index].Index;
return;
}
}
}
}
这篇关于如何在datagridview中找到excel!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文