This is a migrated thread and some comments may be shown as answers.

DropDownClosing and Filter Exception

3 Answers 56 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 21 Jan 2016, 10:07 PM

I updated to 2016 Q1 from 2014.  In 2014, I had worked around the problem of the drop down closing whenever the user tried to click on a filter row by subscribing to the drop down closing event.  Here was the code for that event which worked great for me:

            If TypeOf sender Is RadMultiColumnComboBox Then
                rmc = sender
                If rmc.SelectedIndex > -1 Then
                    '--- if focus is on a row, then let popup close
                    'Console.WriteLine("clicked on: " & CStr(rmc.SelectedIndex))
                Else
                    '--- else, check mouse position and don't allow close if within popup window area
                    pt = rmc.EditorControl.TableElement.PointFromControl(MousePosition)
                    popTop = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Top
                    popLft = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Left
                    popHt = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Height
                    popWd = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Width
                    If pt.X >= popLft And pt.X <= popLft + popWd Then
                        If pt.Y >= popTop And pt.Y <= popTop + popHt Then
                            '--- should be click within window so leave it open
                            args.Cancel = True
                            rmc.Focus()
                        End If
                    End If
                End If

            End If 

Now, when a user clicks on the filter row, it opens the drop down so they can type in a filter but as before, they have to click on it twice to set the focus (a separate bug?). When they make the second mouse click with 2016Q1, I am now getting a null reference exception in Telerik.Wincontrols.UI.  I cannot even trap this error in a Try..Catch, it simply crashes the program.  Screenshot shows situation...user clicks drop down on Cust# field...clicks on filter row in customerName column, has to click again to set the focus and the POOF!

Thanks in advance for help.

 

 


 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Jan 2016, 12:45 PM
Hello Jay,

Thank you for writing.

By design, RadMultiColumnComboBox is not supposed to allow filtering by using the grid filter row. The filtering behavior is available in the editable part of RadMultiColumnComboBox. Additional information is available here: http://docs.telerik.com/devtools/winforms/multicolumncombobox/filtering

However, in order to prevent closing the drop down when typing the filter row, you should focus the active editor in the filter cell. Here is a sample code snippet which result is illustrated on the attached gif file:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)
    Me.RadMultiColumnComboBox1.DataSource = Me.CustomersBindingSource
    Me.RadMultiColumnComboBox1.DisplayMember = "ContactName"
    Me.RadMultiColumnComboBox1.ValueMember = "CustomerID"
    Me.RadMultiColumnComboBox1.AutoSizeDropDownToBestFit = True
    Me.RadMultiColumnComboBox1.EditorControl.EnableFiltering = True
    Me.RadMultiColumnComboBox1.EditorControl.ShowFilteringRow = True
    AddHandler Me.RadMultiColumnComboBox1.DropDownClosing, AddressOf DropDownClosing
End Sub
 
Private Sub DropDownClosing(sender As Object, args As Telerik.WinControls.UI.RadPopupClosingEventArgs)
    If TypeOf sender Is RadMultiColumnComboBox Then
        Dim rmc As RadMultiColumnComboBox = sender
        If rmc.SelectedIndex > -1 Then
            '--- if focus is on a row, then let popup close
            'Console.WriteLine("clicked on: " & CStr(rmc.SelectedIndex))
        Else
            '--- else, check mouse position and don't allow close if within popup window area
            Dim pt As Point = rmc.EditorControl.TableElement.PointFromControl(MousePosition)
            Dim popTop As Integer = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Top
            Dim popLft As Integer = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Left
            Dim popHt As Integer = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Height
            Dim popWd As Integer = rmc.MultiColumnComboBoxElement.MultiColumnPopupForm.Width
            If pt.X >= popLft And pt.X <= popLft + popWd Then
                If pt.Y >= popTop And pt.Y <= popTop + popHt Then
                    '--- should be click within window so leave it open
                    args.Cancel = True
                    If rmc.EditorControl.ActiveEditor IsNot Nothing Then
                        Dim editor As RadTextBoxEditor = TryCast(rmc.EditorControl.ActiveEditor, RadTextBoxEditor)
                        If editor IsNot Nothing Then
                            Dim editorElement As RadTextBoxEditorElement = TryCast(editor.EditorElement, RadTextBoxEditorElement)
                            editorElement.Focus()
                        End If
 
                    End If
                End If
            End If
        End If
    End If
End Sub

Note that the grid may use different editor types. Feel free to modify the above code in a way to suit your requirement best. 

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
fabrizio
Top achievements
Rank 1
Veteran
answered on 19 Jun 2018, 11:56 AM

If RadMultiColumnComboBox should not allow filtering using the grid filter line well then it should
because it works great and really thank you very much for the explanation
Fantastic

Tank you Dess

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Jun 2018, 11:02 AM
Hello, Fabrizio,  

I am glad that the previous explanation was useful. By design, the filtering row in the popup grid is not supposed to be used because the filtering is done through the editable part in RadMultiColumnComboBox

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MultiColumn ComboBox
Asked by
Jay
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
fabrizio
Top achievements
Rank 1
Veteran
Share this question
or