473,471 Members | 4,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGridViwe Find

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

Thanks

Peter
Dec 2 '05 #1
7 1995
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Jones | last post by:
I'm writing a script to process a directory tree of images.  In each directory, I need to process each image and generate an HTML file listing all of the images and links to the subdirectories....
0
by: amit | last post by:
I want to find out that if there is a mechanism to find a text inside a C# file and replace it with another string. I am using DTE to do it, the find proerty does it, the results are getting...
0
by: AMIT PUROHIT | last post by:
hi, this is a qry which I m stuck up with I want to find out that if there is a mechanism to find a text inside a C# file and replace it with another string. I am using DTE(EnvDTE) to do it,...
0
by: amit | last post by:
hi I have created a tool which does a find and replace thru DTE, now after it is done, it opens up a window, "FIND REACHED THE STARTING POINT OF SEARCH" I want to disbale this window...
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
3
by: David T. Ashley | last post by:
Hi, Red Hat Enterprise Linux 4.X. I'm writing command-line PHP scripts for the first time. I get the messages below. What do they mean? Are these operating system library modules, or...
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.