Solved

Rowfilter is disappearing

Posted on 2004-10-01
7
175 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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