Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

Partial searching of a datagridview

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Bravery - 11 Jul 2007 16:59 GMT
Hi all,

I am looking for a way to create partial serching of a datagridview. SO that
as a user would type in a textbox, the position of the row pointer in the
grid would change incrementaly as the user types
so that (searing in 'name' column) if they type "B" the pointer would dind
the start of  names beginnig with 'B', then type 'o', and the pointer moves
to the start of 'Bo' and so on.

Can some one point me in the right direction.

Thanks
Robert
Nicholas Paldino [.NET/C# MVP] - 11 Jul 2007 17:15 GMT
Robert,

   There are a number of things that are going to influence the answer
here.

   The first is, are you using a consistent data source?  Are you always
binding to a datatable/dataview with the same schema, or are you sometimes
binding to a list or something of that nature?  If the underlying data is
going to change, or not consistent (or you have abstracted it out so you
don't have access to the original structure), then you have to cycle through
the rows/cells in a brute-force manner.  Brute-force is required if the data
is not ordered according to your search criteria (in this example, if the
data is not sorted on the name, then you can't really search quickly).

   If you have access to the underlying data, then it's a little easier,
since you can use the methods native to the data container to search, and
then change your selection appropriately.  For example, if you are bound to
a data table, then you can call the Select method to figure out which row
corresponds to the search criteria (and then select it).

   However, this is only the case if the view on the data matches the
underlying data.  If you allow the user to sort the data, then you can't
access the datatable, but rather, you have to access the view that the grid
is bound to, and then search on that.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi all,
>
[quoted text clipped - 9 lines]
> Thanks
> Robert

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.