Add Grpops to List and CloseButton in Search Panel

2 Answers 39 Views
GridView
Hell
Top achievements
Rank 1
Iron
Iron
Hell asked on 02 Jan 2025, 02:22 PM | edited on 02 Jan 2025, 06:08 PM

Hello!
1. How to correctly implement adding unique groups to the list and deleting non-existent ones?
The GroupSummaryEvaluate event does not occur when deleting the last entry in a group (deleting this group). That is, it is necessary for the ListBox to display the same groups as in the Grid.

lbGroups.DataSource = lstGroups.ToList
Public Class Form1
Dim lstGroups As New SortedSet(Of String)
Private Sub grdURLs2_GroupSummaryEvaluate(sender As Object, e As GroupSummaryEvaluationEventArgs) Handles grdURLs2.GroupSummaryEvaluate
        If lstGroups.Add(e.Value) Then
' code
        End If
End Sub
End Class

2. How to remove the Close button from the Search Bar?

For Each row In grdURLs2.TableElement.VisualRows
    If TypeOf row Is GridSearchRowElement Then
        Dim searchRow = TryCast(row, GridSearchRowElement)
        searchRow.SearchCellElement.CloseButton.Visibility = False
        Exit For
    End If
Next
Doesn't work.

Thank you!

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 03 Jan 2025, 08:26 AM

Hello,

1. Following the provided information, it is not very clear what exactly you need to achieve in question 1. Can you please clarify and provide more information about the case that you have. I suppose that you use grouping in RadGridView and you have grouped some columns. The GroupSummaryEvaluate event allows to modify the header text of each group row and customize its appearance: Formatting Group Header Row - WinForms GridView Control - Telerik UI for WinForms

However, can you please specify what exactly you mean by "implement adding unique groups to the list". It would be great if you could provide a sample project or a picture of what you need to have. 

2. To remove the close button from the search row you can use the ShowCloseButton property:

Me.RadGridView1.MasterView.TableSearchRow.ShowCloseButton = False 

I am looking forward to your reply.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Hell
Top achievements
Rank 1
Iron
Iron
commented on 03 Jan 2025, 09:29 AM | edited

2 worked without any problems. Thank you.
1. I want to emulate a list of groups in a ListBox to handle the MouseUp event on a group in it. Accordingly, I need to dynamically display a list of groups in a ListBox.

Private Sub lbGroups_MouseUp(sender As Object, e As MouseEventArgs) Handles lbGroups.MouseUp
    Try
        grdURLs2.ClearSelection()
        For Each item In grdURLs2.Groups
            For Each itm In item
                If itm.Group.GroupRow.Group.Header = lbGroups.SelectedItem.ToString Then 'List of Groups
                    For Each im In itm.Group.GroupRow.ChildRows 'Select all Rows in Group
                        im.IsSelected = True
                    Next
                End If
            Next
        Next
    Catch ex As Exception
        txtError.Text = ex.Message & " - " & Format(Now, "HH:mm:ss")
    End Try
End Sub

If this can be done directly in the Grid, I will be only glad to help. Sorry for my English.

Nadya | Tech Support Engineer
Telerik team
commented on 06 Jan 2025, 11:34 AM

Hello,

I am still not sure if I understand you completely reading your brief description. If I understand you correctly referring to the code snippet, you have a list of groups in list box. On MouseUp event of the list box you clear the selection in a grid called grdURLs2. Can you confirm if grdURLs2 is RadGridView control or if this is something else? Then, I suppose you need to group the grid with the same groups from the list box. Please correct me if I am wrong.

If you need to apply grouping in RadGridView programmatically, you should create and add GroupDescriptors. The GroupDescriptors collection allows you to use descriptors that define the grouping criteria and the group's sorting direction for the data that is bound to the RadGridView. More information and examples are available in the following article: Setting Groups Programmatically - WinForms GridView Control - Telerik UI for WinForms

In case you have different requirements, it would be great to provide more description or a project that can demonstrate what exactly you are trying to achieve.

Please let me know if I can assist you further.

Hell
Top achievements
Rank 1
Iron
Iron
commented on 12 Jan 2025, 10:39 AM | edited

Delete.
Hell
Top achievements
Rank 1
Iron
Iron
commented on 12 Jan 2025, 10:40 AM | edited

Delete.
Hell
Top achievements
Rank 1
Iron
Iron
commented on 12 Jan 2025, 10:42 AM

Hi! I need to select all the Rows in that Group when I click on a Group. Thanks and sorry.
Nadya | Tech Support Engineer
Telerik team
commented on 14 Jan 2025, 11:06 AM

Hello,

I would like to confirm if I understand you correctly. Let's say you have the following grid as in the image below, and the grid is grouped by "Country". After the grid is grouped, groups are automatically created showing data rows in each group.

If I understand you correctly, you would like to select all the data rows in a particular group. Let's say you click on group Argentine, then select the three rows marked in blue. If you click on group Austia, select the two rows marked in green. 

Can you please confirm if this is what you need, or there is something else that I am missing? Before giving you a solution, I would need to know what exactly you are trying to achieve.

I am looking forward to your reply.

Hell
Top achievements
Rank 1
Iron
Iron
commented on 15 Jan 2025, 10:03 AM | edited

Hi! Absolutely right. Thank you!

Hell
Top achievements
Rank 1
Iron
Iron
commented on 16 Jan 2025, 03:12 AM

That's it. Got it. Thank you!

Dim boolChange As Boolean = False

Private Sub grdURLs2_SelectionChanging(sender As Object, e As GridViewSelectionCancelEventArgs) Handles grdURLs2.SelectionChanging
    If Not boolChange Then
        e.Cancel = True
    End If
End Sub

Private Sub grdURLs2_CurrentRowChanging(sender As Object, e As CurrentRowChangingEventArgs) Handles grdURLs2.CurrentRowChanging
    If TypeOf e.NewRow Is GridViewGroupRowInfo Then
        Dim row = TryCast(e.NewRow, GridViewGroupRowInfo)
        boolChange = True
        grdURLs2.ClearSelection()
        For Each item In row.ChildRows
            item.IsSelected = True
        Next
        boolChange = False
    Else
        boolChange = True
    End If
End Sub

Nadya | Tech Support Engineer
Telerik team
commented on 16 Jan 2025, 09:28 AM

Hello, 

I am glad to hear that you managed to find a working solution for your case. You are on the right path. GridViewGroupRowInfo gives you the group row. To get its child rows you should itterate the ChidRows collection. 

If you have any other questions do not hesitate to contact me.

0
Hell
Top achievements
Rank 1
Iron
Iron
answered on 10 Jan 2025, 07:47 AM | edited on 12 Jan 2025, 10:44 AM
Delete.
Tags
GridView
Asked by
Hell
Top achievements
Rank 1
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Hell
Top achievements
Rank 1
Iron
Iron
Share this question
or