有关 BindingSource 中 Find() 的帮助
我用它来查找 DataGridView 中的值:
private void fndBtn_Click(object sender, EventArgs e)
{
BindingSource src = new BindingSource();
src.DataSource = dataGridView1.DataSource;
src.Position = src.Find("p_Name", textBox1.Text);
}
但我有两个问题。首先,当我查找 dgv 中不存在的项目时,position 返回 0,默认情况下是第一行。我不希望这样,如果我使用 If 语句进行验证,我将丢失位置 0,从而丢失第一行。
其次,我希望关注行标题并突出显示找到的项目。这怎么可能?
I use this to look for values in my DataGridView:
private void fndBtn_Click(object sender, EventArgs e)
{
BindingSource src = new BindingSource();
src.DataSource = dataGridView1.DataSource;
src.Position = src.Find("p_Name", textBox1.Text);
}
But I've two issues. First when I look for item that doesn't exist in my dgv, position returns 0 which is by default the first row. I don't want that, and if I verified using If statement I'll lose position 0, thus losing the first row.
Second is I want the row header be focused on and item found be highlighted. How is that possible?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样使用 dataGridView 的绑定源:
Use dataGridView's binding source like this: