We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

event SelectedRecordsChanged not fired

Hi,

I need help with GGC and event SelectedRecordsChanged

My problem is, when I select range of cells, I want to sum value of those cells, like excel


- If I use

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.None;

=> event fired, but not what I desire, and value not sum


- If I use

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.None;

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Any;

=> this is my desire, but event not fired, I have to click button for sum


I have attached sample code for you

Tks


Attachment: CS_c9d4bde8.zip

2 Replies 1 reply marked as answer

HI hieudt March 8, 2023 10:17 AM UTC

Hi,


Can anyone help me ? If you confuse, just asking


Tks



VS Vijayarasan Sivanandham Syncfusion Team March 8, 2023 12:10 PM UTC

Hi Hieudt,

Find the responses to your queries below.

Queries

Responses

- If I use

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.None;

=> event fired, but not what I desire, and value not sum

 

The reported scenario is not an issue. The SelectedRecordsChanging and SelectedRecordsChanged events are triggered only when using the record-based selection. For further details, we have created a new thread for the query, and the link is below.

https://www.syncfusion.com/forums/180976/how-to-get-the-selectedrecord-when-rowbased-selection-enabled-in-gridgroupingcontrol-from

- If I use

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.None;

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Any;

=> this is my desire, but event not fired, I have to click button for sum

 



When you set the ListBoxSelectionMode property to None and the AllowSelection property to a value other than None in the GridGroupingControl, then the model-based selection is used. The TableModel.SelectionChanging and TableModel.SelectionChanged events will trigger only when using the model-based selection. In this case, the selected records can be found in the TableModel.SelectedRanges collection.

So, your requirement to sum the values contained in the selected range of cells in the GridGroupingControl can be achieved by using the SelectionChanging or SelectionChanged events. Refer to the below code snippet,

 

//Case 2: Model based selection

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.None;

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Any;

 

//Event subscription

this.gridGroupingControl1.TableModel.SelectionChanging += OnSelectionChanging;

this.gridGroupingControl1.TableModel.SelectionChanged += OnSelectionChanged;

 

//Event customization

private void OnSelectionChanged(object sender, GridSelectionChangedEventArgs e)

{

    //Here cutomize based on your scenario

    Calculate_range_records();

}

 

//Event customization

private void OnSelectionChanging(object sender, GridSelectionChangingEventArgs e)

{

    //Here cutomize based on your scenario

    Calculate_range_records();

}


UG Link: https://help.syncfusion.com/windowsforms/gridgrouping/selections#model-based-selection


Find the modified sample in the attachment.


Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: GridGroupingControlDemo_3bd50742.zip

Marked as answer
Loader.
Up arrow icon