Solved

Rowfilter is disappearing

Posted on 2004-10-01
7
169 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
Comment Utility
Is Threading a necessary evil here?  It is fairly complex, and IMHO should not be used lightly.

Bob
0
 

Author Comment

by:malanois
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:malanois
Comment Utility
Could you explain?
0
 

Author Comment

by:malanois
Comment Utility
By the way, lots o data

datagrid 2 and 3 both each are 257,000 records

0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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
Comment Utility
Done and fixed, It was a problem with the threading.

The dataset and rowfilter must be in the same thread


malanois
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now