471,321 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

DataGridViwe Find

How do I do Search in DataGridView and make the found row visible in UI?

Thanks

Peter
Dec 2 '05 #1
7 1882
Hi Peter,

Do you mean that your DataGridView is binding to a DataSet and you need to
find in the DataSet values?

If so, you can use DataTable.Select method to find the rows that meet your
criteria. Please check the following link for more information.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatableclassselecttopic.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 3 '05 #2

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:RM**************@TK2MSFTNGXA02.phx.gbl...
Hi Peter,

Do you mean that your DataGridView is binding to a DataSet and you need
to
find in the DataSet values?

If so, you can use DataTable.Select method to find the rows that meet your
criteria. Please check the following link for more information.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatableclassselecttopic.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


I can find the row, but how do I make the row that contains the search value
visible in the DataGridView if the DataGridView displays only 20 records at
a time and the search record is the 100th record?
Dec 4 '05 #3
Hi Peter,

Are you using a DataView as the data source of the DataGridView? If so, we
cannot make it visible unless the row meets the criteria of the filter.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 6 '05 #4

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:iU****************@TK2MSFTNGXA02.phx.gbl...
Hi Peter,

Are you using a DataView as the data source of the DataGridView? If so, we
cannot make it visible unless the row meets the criteria of the filter.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


I do have a criteria filter which does find the desiried row, but the row
never becomes visible in the grid if it's not visible when the search
started. How do I make the row visible in the DataGridView after I find the
row in the DataView?

System.Data.DataView dvOpenOrders;
.....
.....
this.dvOrders.Table = dt.GetOrders();
this.dataGridView1.DataSource = this.dvOpenOrders.Table;

this.dvOrders.Sort = "id";
object[] findKey = new object[1];
DataColumn[] dcolPk = new DataColumn[1];
dcolPk[0] = tbl.Columns["id"];
tbl.PrimaryKey = dcolPk;
tbl.DefaultView.Sort = "id";
findKey[0] = id;
row = tbl.DefaultView.Find(findKey);
Dec 6 '05 #5
Hi Peter,

Do you mean that before searching, the row is not visible. And after
searching, you need to make the row visible? If so, we can only make it
visible when the row meets the criteria of the DataView. If you need help
on how to make it meet the criteria, please provide the code you're using
to set the criteria.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 7 '05 #6

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:C9****************@TK2MSFTNGXA02.phx.gbl...
Hi Peter,

Do you mean that before searching, the row is not visible. And after
searching, you need to make the row visible? If so, we can only make it
visible when the row meets the criteria of the DataView. If you need help
on how to make it meet the criteria, please provide the code you're using
to set the criteria.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Yes, before searching, the row is not visible and after searching I need to
make the row visible

The following code finds the row but does not make it visible.

System.Data.DataView dvOpenOrders;
.....
.....
this.dvOrders.Table = dt.GetOrders();
this.dataGridView1.DataSource = this.dvOpenOrders.Table;

this.dvOrders.Sort = "id";
object[] findKey = new object[1];
DataColumn[] dcolPk = new DataColumn[1];
dcolPk[0] = tbl.Columns["id"];
tbl.PrimaryKey = dcolPk;
tbl.DefaultView.Sort = "id";
findKey[0] = id;
row = tbl.DefaultView.Find(findKey);

Dec 7 '05 #7
Hi Peter,

I don't quite understand your code, because you're setting a DataTable as
the DataSource and what's dvOpenOrders? What is the default view for tbl?

As I mentioned in my last post. If you can use Find to find the row in a
DataView, it must be visible before and after it is found. If a row is
filtered out by the DataView, it you are not able to display it, unless you
change the filter criteria or change value of the row.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 9 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dan Jones | last post: by
reply views Thread by amit | last post: by
reply views Thread by AMIT PUROHIT | last post: by
5 posts views Thread by Mike Labosh | last post: by
3 posts views Thread by David T. Ashley | last post: by
reply views Thread by Derek | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.