Solved

Rowfilter is disappearing

Posted on 2004-10-01
7
170 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

16 Experts available now in Live!

Get 1:1 Help Now