/// <summary> /// Trigger the sort string changed method /// </summary> public void TriggerSortStringChanged() { //call event handler if one is attached SortEventArgs sortEventArgs = new SortEventArgs { SortString = _sortString, Cancel = false }; //invoke SortStringChanged if (_sortStringChangedInvokeBeforeDatasourceUpdate) { if (SortStringChanged != null) { SortStringChanged.Invoke(this, sortEventArgs); } } //sort datasource if (sortEventArgs.Cancel == false) { BindingSource datasource = this.DataSource as BindingSource; if (datasource != null) { datasource.Sort = sortEventArgs.SortString; } } //invoke SortStringChanged if (!_sortStringChangedInvokeBeforeDatasourceUpdate) { if (SortStringChanged != null) { SortStringChanged.Invoke(this, sortEventArgs); } } }
/// <summary> /// Trigger the sort string changed method /// </summary> public void TriggerSortStringChanged() { //call event handler if one is attached SortEventArgs sortEventArgs = new SortEventArgs { SortString = _sortString, Cancel = false }; if (SortStringChanged != null) { SortStringChanged.Invoke(this, sortEventArgs); } //sort datasource if (sortEventArgs.Cancel == false) { if (this.DataSource is BindingSource datasource) { datasource.Sort = sortEventArgs.SortString; } } }