help with filter on datagrid

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2006
Posts: 4
Reputation: cynical is an unknown quantity at this point 
Solved Threads: 0
cynical cynical is offline Offline
Newbie Poster

help with filter on datagrid

 
0
  #1
Jan 24th, 2009
Hi!

I'm using VS 2003 and MS Access. I have this Form1 that displays Record details on textboxes (they are databinded).. The records are retrieved from MS Access using the code:

  1. Public Sub loadFund()
  2. '[Load Items]
  3. Dim selectAllSQL as string = "SELECT * FROM Table1"
  4. Dim selectAllCMD As OleDbCommand = New OleDbCommand(selectAllSQL, theConnection)
  5. theAdapter.SelectCommand = selectAllCMD
  6.  
  7. theData = New DataSet
  8. theAdapter.Fill(theData, "Table1")
  9. '[Load Items /]
  10. End Sub

I have a search function that will show a datagrid on the lower part of the form. So far I was able to filter searches using this code.

  1. Dim dv As New DataView(theData.Tables("Table1"))
  2. dv.RowFilter = "itmAmt = " & "'" & txtSearch.Text & "'"
  3. DataGrid1.DataSource = dv

The filter works fine, but I have one problem. The main form (that contains the record details)does not navigate along when I navigate thru the datagrid. I want to be able to do that. So when the user finds what he's looking for from the filtered results, he could just double click on the datagrid row and the row that was double clicked would show on the main form so he could edit it or something using the main form. How is this possible? Please help me, its driving me crazy.
Last edited by cynical; Jan 24th, 2009 at 8:51 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: help with filter on datagrid

 
1
  #2
Jan 25th, 2009
on datagrid double click event, get data on selected then show it on main form.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 4
Reputation: cynical is an unknown quantity at this point 
Solved Threads: 0
cynical cynical is offline Offline
Newbie Poster

Re: help with filter on datagrid

 
0
  #3
Jan 25th, 2009
thanks for replying. I already found a solution. I filtered the result from another grid and when the user double click one of the results, it will select the corresponding row on my main grid that is databinded on my main form.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: help with filter on datagrid

 
0
  #4
Jan 26th, 2009
very good. Would you like to share with us how to do it, so if other members get the same problem they can solved it.
And don't forget to mark this thread as solved..
Thanks
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 4
Reputation: cynical is an unknown quantity at this point 
Solved Threads: 0
cynical cynical is offline Offline
Newbie Poster

Re: help with filter on datagrid

 
0
  #5
Jan 26th, 2009
Sure,

I had two datagrids. One (datagrid1) was binded on my main form and the other (datagrid2) I used to filer. After filter, the user should double click a row from the results from datagrid2 and it will automatically select the corresponding row from datagrid1.

Using this code on my datagird2_doubleclick

  1. Dim _id As Integer
  2. Dim i As Integer
  3. _id = datagrid2(datagrid2.CurrentRowIndex, 0).ToString()
  4.  
  5. For i = 0 To cFT.theData.Tables("tbl1").Rows.Count - 1
  6. datagrid1.UnSelect(i)
  7. If datagrid1(i, 0).ToString = _id Then
  8. datagrid1.Select(i)
  9. datagrid1.ScrollToRow(i)
  10. datagrid2.Visible = False
  11. End If
  12. Next
  13.  
  14. datagrid1.Focus()
Last edited by cynical; Jan 26th, 2009 at 8:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: help with filter on datagrid

 
0
  #6
Jan 29th, 2009
Thx For sharing...
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC