943,844 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3565
  • VB.NET RSS
Jan 24th, 2009
0

help with filter on datagrid

Expand Post »
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:

VB.NET Syntax (Toggle Plain Text)
  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.

VB.NET Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cynical is offline Offline
4 posts
since Nov 2006
Jan 25th, 2009
3

Re: help with filter on datagrid

on datagrid double click event, get data on selected then show it on main form.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,140 posts
since Nov 2007
Jan 25th, 2009
0

Re: help with filter on datagrid

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cynical is offline Offline
4 posts
since Nov 2006
Jan 26th, 2009
3

Re: help with filter on datagrid

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
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,140 posts
since Nov 2007
Jan 26th, 2009
0

Re: help with filter on datagrid

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

VB.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cynical is offline Offline
4 posts
since Nov 2006
Jan 29th, 2009
1

Re: help with filter on datagrid

Thx For sharing...
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,140 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Convert a word in kanji to katakana or vice-versa.
Next Thread in VB.NET Forum Timeline: How to connect vb.net in the internet?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC