Solved

Search DataGrid

Posted on 2004-10-16
4
228 Views
Last Modified: 2010-04-23
I am currently using the following code to search a datagrid

DsLocation.Tables("tblscanorder").DefaultView.Sort = "SalesOrder"
        BindingContext(DsLocation, "tblscanorder").Position = DsLocation.Tables("tblscanorder").DefaultView.Find(TxbSearch.Text)

The field saleorder have 9 characters, I want to be able to do the search on the last 5 only as the first 4 are always the same

Example

Sales order = SOR079377

So I want to search for 79377
0
Comment
Question by:davidrichardson
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12327005
use the EndsWith property of the string object.

str.EndsWith("79377")
0
 
LVL 7

Author Comment

by:davidrichardson
ID: 12327066
could you give me a bit more information, Where would i use this
0
 
LVL 10

Accepted Solution

by:
Hans Langer earned 75 total points
ID: 12327525
     Dim i As Int32

      For i = 0 To ds.Tables("tblscanorder").DefaultView.Count - 1
         If Convert.ToString(ds.Tables("tblscanorder").DefaultView.Item(i).Item("TheColumnIndex")).EndsWith("79375") Then Exit For
      Next

 BindingContext(DsLocation, "tblscanorder").Position = i
0
 
LVL 7

Author Comment

by:davidrichardson
ID: 12328165
That Works Great

Thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I need help embedding an image as HTML in my vb.net application 3 69
VB.Net How to Exit Sub - Exit Form??? 5 58
VB.NET 1 24
Expression Evaluater 3 27
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question