DataGrid Selection Begin/End Update failure

Posted by: rand.random on 6 February 2018, 1:45 am EST

    • Post Options:
    • Link

    Posted 6 February 2018, 1:45 am EST

    Today we wanted to improve our performance on our Datagrid where we select Datagrid Cells depending on some Settings the User can change.

    Up to today we just used Selection.Add() and Selection.Remove()

    As i said we wanted to speed this up since the Datagrid can have 40.000 lines and we added a call Selection.BeginUpdate() before we Add several Columns and added the Selection.EndUpdate() after we added all Columns and Removed all unwanted Rows.

    So our way up to now was:

    1. Add Columns 1-X
    2. Remove Rows 1-X

    now we have:

    1. BeginUpdate()
    2. Add Columns 1-X
    3. Remove Rows 1-X
    4. EndUpdate()

    While testing the new implementation we had to find out that the system is not working as before.

    The reason: When using BeginUpdate and EndUpdate the Remove from the Selection is simple not done.

    In our opinion this is fundamentally wrong. The result using BeginUpdate/EndUpdate and doing the same without BeginUpdate/EndUpdate should always be the same. after the whole block is processed.

    Demo Code (DataGrid with 10 Rows, 2 Columns):

                
    DemoGrid.Selection.Clear();
    	    DemoGrid.Selection.BeginUpdate();
    DemoGrid.Selection.Add(DemoGrid.Columns[0], DemoGrid.Columns[0]);
                DemoGrid.Selection.Remove(DemoGrid.Rows[0], DemoGrid.Rows[0]);
                DemoGrid.Selection.EndUpdate();
    
    

    Result in this case is that every Cell in First Column is selected.

                
    DemoGrid.Selection.Clear();
    DemoGrid.Selection.Add(DemoGrid.Columns[0], DemoGrid.Columns[0]);
                DemoGrid.Selection.Remove(DemoGrid.Rows[0], DemoGrid.Rows[0]);
    
    

    Result in this case is that all Cells in the First Column are selected exceptthe Cell from First Row/FirstColumn

    So there are different results when using BeginUpdate and EndUpdate.

    greetings

  • Posted 6 February 2018, 5:50 pm EST

    Hi,

    I escalated this to concern team. Will let you know as soon as there is any information from them.

    (TFS ID : 307933 for internal use only)

    Thanks,

    Singh

  • Posted 18 February 2018, 6:00 pm EST

    Hi,

    As per developer team, this behavior is by design, as there is no effective way to keep history of all operations between BeginUpdate/EndUpdate calls and then repeating them all in EndUpdate.

    Thanks,

    Singh

  • Posted 23 February 2018, 1:18 am EST

    Thank you for that information.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels