编写所需的单词显示在文本框中。我想有多行...但是,通过此代码,我只得到一行选择.. ,我想输出到屏幕行..而不是绘画,我想只显示指定的行(匹配文本框的文本)。如何实现这一目标?C#如何更改我的代码?
try
{
dataGridView1.ClearSelection(); //or restore rows backcolor to default
for (int i = 0; i < (dataGridView1.Rows.Count); i++)
{
for (int j = 0; j < (dataGridView1.Columns.Count); j++)
if (dataGridView1.Rows[i].Cells[j].Value.ToString().StartsWith(txbSearchName.Text, true, CultureInfo.InvariantCulture))
//(dataGridView1.Rows[i].Cells[j].Value.ToString().StartsWith(txbSearchName.Text, true, CultureInfo.InvariantCulture))
{
dataGridView1.FirstDisplayedScrollingRowIndex = i;
dataGridView1.Rows[i].Selected = true; //It is also possible to color the row backgroud
return;
}
}
}
catch (Exception)
{
MessageBox.Show("not exist");
}
你只想过滤网格的数据源? – Sachin
也许......?对不起,我不好英语..我做了,使用datagridview..load csv文件..不使用数据表..所以,然后我想过滤搜索功能。 – Simkyujin
Windows桌面应用程序? – Sachin