AdvancedFilter FirstConditionComboBox

Hi, I'm using Winforms 20.2.0.40 and can't set programmatically FirstConditionComboBox.SelectedValue in a AdvancedFilter:

sfDataGridProdotti.FilterPopupShowing += sfDataGrid_FilterPopupShowing;

void sfDataGrid_FilterPopupShowing(object sender, FilterPopupShowingEventArgs e)

        {

            try

            {

                if (e.Column.MappingName == "Cognome")

                {

                    e.Control.FilterPopupMode = FilterPopupMode.AdvancedFilter;

                    e.Control.AdvancedFilterType = AdvancedFilterType.TextFilter;

                    e.Control.FirstConditionComboBox.SelectedIndex = 7;

                    e.Control.FirstConditionComboBox.Text = "Contains";

                    e.Control.ImmediateUpdateColumnFilter = true;

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.ToString());

            }

        }


this code dont change the default value "Equals" of first combobo


3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team August 3, 2022 03:58 PM UTC

Hi Massimo,

Your requirement to change the default AdvancedFilter FirstConditionComboBox value in SfDataGrid can be achieved by customizing the FilterPopupShown event. Please refer to the below code snippet,


sfDataGrid1.FilterPopupShown += OnFilterPopupShown;

 

private void OnFilterPopupShown(object sender, Syncfusion.WinForms.DataGrid.Events.FilterPopupShownEventArgs e)

{

 

            try

            {

                if (e.Column.MappingName == "Cognome")

                {

                    //here change the AdvancedFilter FirstConditionComboBox defult value

                    e.Control.FirstConditionComboBox.SelectedIndex = 7;

                    e.Control.FirstConditionComboBox.Text = "Contains";                  

 

                }

 

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.ToString());

            }

}


API Link: https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.SfDataGrid.html#Syncfusion_WinForms_DataGrid_SfDataGrid_FilterPopupShown

UG Link: https://help.syncfusion.com/windowsforms/datagrid/filtering#skip-the-frozen-row-data-from-filtering

Please find the sample in the attachment and let us know if you have any concerns in this.


Regards,

Vijayarasan S


Attachment: Sample_7de87626.zip


MA Massimo August 4, 2022 07:15 AM UTC

Hi  Vijayarasan, 

thank you very much. This solve my problem.



VS Vijayarasan Sivanandham Syncfusion Team August 4, 2022 01:22 PM UTC

Hi Massimo,

If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you😊.

Regards,

Vijayarasan S


Marked as answer
Loader.
Up arrow icon