?
Solved

searching through datagrid

Posted on 2004-08-28
4
Medium Priority
?
156 Views
Last Modified: 2010-08-05
I have one datagrid thats populated with xml data. I want to have a text box to allow a user to search through datagrid 1 and dispaly the found results in datagrid2. can some1 give me some example code. would i just use the same as the datagrid 1 and use filter function?(I would prefer using the same dataset cause i want to allow user to change at later stages

0
Comment
Question by:DelphiCurious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 11924811
Hello

  Use dataView to help you to accomplish that

Here's an example to show all data from xml file in dataGrid1, and the search for a value and show the result in dataGrid2

...... Windows Form Designer generated code

    Dim ds As New DataSet

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dv As New DataView(ds.Tables(0))
        dv.RowFilter = "FirstName = '" & TextBox1.Text & "'"
        DataGrid2.DataSource = dv
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ds.ReadXml("c:\emp.xml")
        DataGrid1.DataSource = ds.Tables(0)
    End Sub

If you would like the result to showed in the same grid, you can use the Default DataView of DataTable
as
Ds.Tables(0).DefaultView.RowFilter = ...

if you want to clear the Filter just set the RowFilter property to empty string

HTH

Regards,
Mohammed Nasman
0
 

Author Comment

by:DelphiCurious
ID: 11927753
it works but it searches the first column and i want to search the third
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 1600 total points
ID: 11928776
Hello

  I used FirstName field, you need to change it to any field you like
for example
dv.RowFilter = "FirstName '" ..
if would like to use LastName instead just change it
dv.RowFilter = "LastName '"..
0
 
LVL 2

Expert Comment

by:chrisryhal
ID: 13135155
Is there a way someone could help me out with my problem?  Kinda the same thing.  What I previously have had one expert help me with, has really not helped much.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21284699.html
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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