Problem with spanning after Rows.Remove

Jul 9, 2009 at 2:47 PM
Edited Jul 9, 2009 at 2:48 PM

Hi.

I've another problem/question with SourceGrid and the use of column spanning.

If I remove a row with spanned columns, there is a little problem: I can't select the spanned cells that are below the one which has been removed, because there is a reference/table that seems no to be updated.
I can select the spanned cell if I click on the first column of the spanning, but not the other.

I can see that there is a problem when I use spanned ColumnHeader: after removing a row above the header, the ColumnHeader is highlighted when the mouse is over the cell one line below. There is an "offset" of 1 row (the one I deleted). So I think that a table of spanned cells which is used with MouseMouse/MouseClick isn't updated after a row removal.

What should I do ? Is there a method to call to reset this ?

 

In this example, if I remove a row between lines 16/17 and then go with the mouse cursor on the line 20, the ColumnHeader between lines 19 and 20 is highlighted.
And if I click on the line 20, I can't select it, except if I'm on the first column of this spanned cell.

Jul 9, 2009 at 3:02 PM

And with the last update (25856, but was also the case with some previous ones), the performance with spanned cells is very awful again! The span performance patch isn't in the trunk?

Coordinator
Jul 14, 2009 at 7:11 AM

It is in the trunk, already for two weeks there.

have a look at example four, it adds 2000 rows with span of 200 columns in just a second.

Maybe you hit another slow point in SourceGrid?

A test case would be very very welcome!



Jul 15, 2009 at 1:55 PM

No I didn't change anything in spanning management since last correction from Lafriks.

And what about the other thing? I'm experiencing many problems when adding and removing rows between spanned rows!

Is there a problem with "spannedCellReferences"? Is there a way to rebuild/update this Dictionary  with a public function ?

Coordinator
Jul 15, 2009 at 5:31 PM

Could you provide a working code which would reproduce this?

Jul 15, 2009 at 7:14 PM

With the following code, you'll see that you can't select correctly the spanned cell (except if you click in the cell under the 1st column, but select takes the header with).

And if you hover the spanned cell, the header which is one line upper will be highlighted. So we can see that some references for spanned cells aren't updated when a row is removed.
And also when a row is inserted...

Same problem without header, the spanned cell cannot be selected correctly when a row above has been removed.

 

           // Resize grid
            grid1.ColumnsCount = 10;
            grid1.RowsCount = 10;
// Header
            for (int c = 0; c < grid1.ColumnsCount; c++)
                grid1[0, c] = new SourceGrid.Cells.ColumnHeader("Col" + c.ToString());
// Insert some non-spanned cells
            for (int r = 1; r < 5; r++)
            {
for (int c = 0; c < grid1.ColumnsCount; c++)
                {
                    grid1[r, c] = new SourceGrid.Cells.Cell("(" + r.ToString() + "," + c.ToString() + ")");
                }
            }
// Insert one spanned header
            grid1[5, 0] = new SourceGrid.Cells.ColumnHeader("Col0-9");
            grid1[5, 0].ColumnSpan = 10;
// Insert one spanned cell
            grid1[6, 0] = new SourceGrid.Cells.Cell("(6,0)");
            grid1[6, 0].ColumnSpan = 10;
// Insert some non-spanned cells
            for (int r = 7; r < 10; r++)
            {
for (int c = 0; c < grid1.ColumnsCount; c++)
                {
                    grid1[r, c] = new SourceGrid.Cells.Cell("(" + r.ToString() + "," + c.ToString() + ")");
                }
            }
// Remove one row above spanned cell
            grid1.Rows.Remove(3);

Jul 17, 2009 at 12:13 PM

I would be very happy if someone could explain/recapitulate me how the spanned cell references are managed, because I'm experiencing many problems when adding/removing rows.

If I insert a row, now I get such an error:

+        e    {SourceGrid.OverlappingCellException: Given cell at position (10, 2), intersects with another cell at position (11, 2) ''
   at SourceGrid.Grid.EnsureDestinationSpannedAreaIsEmptyExceptOriginalCell(Int32 row, Int32 col, ICell p_cell) in D:\PROJECTS\VS2008\_SourceGrid\SourceGrid4\SourceGrid\Grids\Grid.cs:line 325
   at SourceGrid.Grid.OccupySpannedArea(Int32 row, Int32 col, ICell p_cell) in D:\PROJECTS\VS2008\_SourceGrid\SourceGrid4\SourceGrid\Grids\Grid.cs:line 391
   at SourceGrid.Cells.Cell.SetSpan(Int32 rowSpan, Int32 colSpan) in D:\PROJECTS\VS2008\_SourceGrid\SourceGrid4\SourceGrid\Cells\Cell.cs:line 199}    SourceGrid.OverlappingCellException

And I never make a spanning which is on several rows, so I this it the same problem has explained above with cell selection and header highlight.

I unfortunately can't work with this control since this problem exists and I would be sad if I had to choose another grid control, but if I can't correct these bugs, it's what I'll have to do.
If I can correct (temporarily) some of these things myself, it's ok, but there are so few comments that it's not so easy to know where you to begin...

Any tips ?

Thanks

Jul 17, 2009 at 12:17 PM
To temporarily fix your problem, download my patch that I just uploaded yesterday, which allows you to disable the overlapping cell check (since I want to allow cells to overlap) then in your form constructor call grid.AllowOverlappingCells=true;
 
Cheers,
Derek

On Fri, Jul 17, 2009 at 8:14 AM, jray <notifications@codeplex.com> wrote:

From: jray

I would be very happy if someone could explain/recapitulate me how the spanned cell references are managed, because I'm experiencing many problems when adding/removing rows.

If I insert a row, now I get such an error:

+        e    {SourceGrid.OverlappingCellException: Given cell at position (10, 2), intersects with another cell at position (11, 2) ''
   at SourceGrid.Grid.EnsureDestinationSpannedAreaIsEmptyExceptOriginalCell(Int32 row, Int32 col, ICell p_cell) in D:\PROJECTS\VS2008\_SourceGrid\SourceGrid4\SourceGrid\Grids\Grid.cs:line 325
   at SourceGrid.Grid.OccupySpannedArea(Int32 row, Int32 col, ICell p_cell) in D:\PROJECTS\VS2008\_SourceGrid\SourceGrid4\SourceGrid\Grids\Grid.cs:line 391
   at SourceGrid.Cells.Cell.SetSpan(Int32 rowSpan, Int32 colSpan) in D:\PROJECTS\VS2008\_SourceGrid\SourceGrid4\SourceGrid\Cells\Cell.cs:line 199}    SourceGrid.OverlappingCellException

And I never make a spanning which is on several rows, so I this it the same problem has explained above with cell selection and header highlight.

I unfortunately can't work with this control since this problem exists and I would be sad if I had to choose another grid control, but if I can't correct these bugs, it's what I'll have to do.
If I can correct (temporarily) some of these things myself, it's ok, but there are so few comments that it's not so easy to know where you to begin...

Any tips ?

Thanks

Read the full discussion online.

To add a post to this discussion, reply to this email (sourcegrid@discussions.codeplex.com)

To start a new discussion for this project, email sourcegrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jul 17, 2009 at 2:22 PM

Thanks very much for this workaround. It's nearly what I've tried (I replaced "throw new OverlappingCellException" with "existingSpannedCell = null") and now I don't have these exceptions.

But the cell selection don't work correctly, because sometimes many cells which aren't spanned are selected. I thinks it's because the list/dictionary of spanned cells isn't updated.

But it's already a little bit better because it doesn't crash the application !

Coordinator
Jul 22, 2009 at 6:02 AM

jray, thank you for invidicating this bug to us.

 

When you told that it occurs only when inserting and removing rows / cols, i understood what is the problem. The problem is in the way we store the references to spanned cells. More specifically - how we calculate the hash, since we store everything in dictionary. I will think of some solution and will post it.

Jul 24, 2009 at 1:35 PM

OK, it's temporarily OK now.

I'm looking forward for the correction of this problem, after that SourceGrid won't be so far form perfection for me :)

 

And about my performance problem, I found that it isn't a Span problem any more, but comes with "grid.AutoSizeCells()" (35 secs with, 4 secs without, with 10000 rows and 27 cols)