Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
How to treat clicking on header checkbox as a single change of value
posted

Hi

I have UltraCombo bound to data source. It has also one unbound column of checkbox type. Initially all rows are unchecked.

I discovered that when I click on this column's header check box the Value property changes step-by-step i.e. I have a series of ValueChanged events with 1st row checked then 1st and 2nd rows checked etc.

Problem is that after changing the value I have to hit database so when I try to check all rows it just stucks so I would like to have one query to database after check of uncheck all rows with one click.

I played with OnBeforeHeaderCheckBoxStateChanged method (using control inherited directly from UltraCombo) and here is sample code:

protected override void OnBeforeHeaderCheckBoxStateChanged(BeforeHeaderCheckStateChangedEventArgs e)
        {
            base.OnBeforeHeaderCheckBoxStateChanged(e);
            switch (e.NewCheckState)
            {
                case CheckState.Checked:
                    Value = Rows.Select(x => x.Cells[ValueMember].Value).ToList();
                    e.Cancel = true;
                    break;
                case CheckState.Unchecked:
                    Value = new List<object>();
                    e.Cancel = true;
                    break;
            }
        }

After doing this I almost got what I want but the problem is that the text in displaying part of combo is not being updated untill combo lost its focus even the rows are checked when I open dropdown again. Am I doing something wrong is there any way to do it better?

Thanks

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

    It seems like a better thing to do would be to simply set a flag inside of OnBeforeHeaderCheckBoxStateChanged. Then check that flag inside ValueChanged and if the flag is set, skip your ValueChanged code.

    Then in the OnAfterHeaderCheckBoxStateChanged, do your processing for ValueChanged.

Reply Children
No Data