Solved

Rowfilter is disappearing

Posted on 2004-10-01
7
174 Views
Last Modified: 2010-04-23
This is a good one,

I have 2 datagrid that are being filtered from another datagrid.  On mouse click event from datagrid1 a variable is being generated.  It then filters datagrid 2, and datagrid3 accordingly.  IT IS FILTERING.  However after the filter datagrid 2 and 3 go back to a blank datagrid.

Here is some code

Private Sub datagridClick(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles DataGrid.MouseDown
        Dim mouseClick As DataGrid.HitTestInfo
        Dim descIndex As Integer
        Dim picIndex As Integer

        If e.Button = MouseButtons.Left Then

            dgObservation = CType(sender, DataGrid)
            mouseClick = DataGrid.HitTest(e.X, e.Y)
            gridRow = mouseClick.Row

            'Get variable of selected rows

            On Error Resume Next
            PnIndex = Me.DbDataSet.T_PARTS.Columns.IndexOf("TRDB_PN")
            Pnname = Me.DbDataSet.T_PARTS.Rows(gridRow)(PnIndex).ToString

            pnmainIndex = Me.DbDataSet.T_PARTS.Columns.IndexOf("PART_NUM")
            pnmain = Me.DbDataSet.T_PARTS.Rows(gridRow)(pnmainIndex).ToString

      Filter_dataview()                <--------- new thread to filter
        End If
          End Sub


Public Sub Filter_dataview()
        Dim workthread2 As New System.Threading.Thread(AddressOf filterdatagrid)
        workthread2.Start()
    End Sub

    Private Sub filterdatagrid()

        dv2.RowFilter = "CHLD = '" & pnmain & "'"   <<<<<<<<--
        dv3.RowFilter = "PRNT = '" & pnmain & "'"  <<<<<<<<<<        These are working
                     
                                           <<<<<<<<<<<<< After the filter this is were it is disapearing
    End Sub
0
Comment
Question by:malanois
  • 4
  • 3
7 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 12200144
Is Threading a necessary evil here?  It is fairly complex, and IMHO should not be used lightly.

Bob
0
 

Author Comment

by:malanois
ID: 12200908
OK,

If I dont use the thread, my program takes quite a while to complete the filtering.

I mean a while, and the program kind of hangs.

If i click on 1 row I must wait 5-6 seconds to click on another row.

If i use the multithread i have no problems

malanois
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12201061
How much data are you working with here?  Do you need the functionality of a DataSet over a DataReader?  

It could be possible to fill datagrid 2 and 3 with DataReaders and a different version of the Select statement that filled datagrid 1--without having to deal with filters.

Bob
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:malanois
ID: 12201626
Could you explain?
0
 

Author Comment

by:malanois
ID: 12201650
By the way, lots o data

datagrid 2 and 3 both each are 257,000 records

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12201717
How useful is a datagrid with 257,000 records?

If SQL for 1 = "Select Name From Table"

Then SQL for 2 = "Select Name From Table Where Date Between '01/01/2004' And '10/1/2004' "

Then SQL for 3 = "Select Name From Table Where Date Between '01/01/2004' And '10/1/2004' And Name = 'Bob' "

Bob
0
 

Author Comment

by:malanois
ID: 12226424
Done and fixed, It was a problem with the threading.

The dataset and rowfilter must be in the same thread


malanois
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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