473,699 Members | 2,364 Online
Bytes | Software Development & Data Engineering Community
+ 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 2007
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.Selec t 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/
frlrfsystemdata datatableclasss electtopic.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.mic rosoft.com> wrote in message
news:RM******** ******@TK2MSFTN GXA02.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.Selec t 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/
frlrfsystemdata datatableclasss electtopic.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.mic rosoft.com> wrote in message
news:iU******** ********@TK2MSF TNGXA02.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.Dat aView dvOpenOrders;
.....
.....
this.dvOrders.T able = dt.GetOrders();
this.dataGridVi ew1.DataSource = this.dvOpenOrde rs.Table;

this.dvOrders.S ort = "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.mic rosoft.com> wrote in message
news:C9******** ********@TK2MSF TNGXA02.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.Dat aView dvOpenOrders;
.....
.....
this.dvOrders.T able = dt.GetOrders();
this.dataGridVi ew1.DataSource = this.dvOpenOrde rs.Table;

this.dvOrders.S ort = "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
7589
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. Just about every source I can find on the 'net for processing subdirectories points you at Find::Find.  However, I'm trying to do something like this: enter directory open INDEX, ".\index.html" print INDEX HTMLheader
0
2769
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 displayed in a find results window pane , but I m not able to programmatically take the contents of the pane. DTE.Find.FindWhat = "catch" DTE.Find.Target = vsFindTarget.vsFindTargetFiles DTE.Find.MatchCase = False DTE.Find.MatchWholeWord = False...
0
2577
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, the find proerty does it, the results are getting displayed in a find results window pane , but I m not able to programmatically take the contents of the pane.
0
2121
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 programmatically. how should i do it this is a partial code Dim dsData As DataSe
5
3014
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 CancelEventArgs that lets me cancel the Close() operation, but is there still any way to find out *why* a form is closing? This app as a form that needs to be loaded at startup, closed only at shutdown, and then Show() / Hide() for the user. If...
3
7211
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 'mscorlib' (Signature='B77A5C561934E089' Version='1.0.5000.0') of assembly 'System.dll' WARNING: Unable to find dependency 'mscorlib' (Signature='B77A5C561934E089' Version='1.0.5000.0') of assembly 'System.Windows.Forms.dll' WARNING: Unable to...
3
16509
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 something in PHP that I don't have? Do I need to install more Linux packages? Or adjust PHP in some way?
0
11266
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 information for the". I am using Cassini as the web server on my PCand I can still run my site from within VWD. Does anyone know what I have done to cause these messages to appear? Could not find schema information for the element...
0
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8617
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
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 we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.