/// <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);
                }
            }
        }
Beispiel #2
0
        private void AdvancedDataGridView_main_SortStringChanged(object sender, Zuby.ADGV.SortEventArgs e)
        {
            //eventually set the SortString here
            //if e.Cancel is set to true one have to update the datasource here
            //bindingSource_main.Sort = advancedDataGridView_main.SortString;
            //otherwise it will be updated by the component

            textBox_sort.Text = e.SortString;
        }
        /// <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;
                }
            }
        }