
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
Thank you!
2 Answers, 1 is accepted
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.
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.
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.
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.
Hi! Absolutely right. Thank you!
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
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.
