# Sort with merged cells

Good mornig to all,

j have a grid with 5 columns:

1 : Producrt code

2 : Product Name

3 : Price

4 : Vat

5 : Final price

The grid is sorted Name with asceding direction

Till now it's all ok

The problem apperars when j need to insert a comment in the grid, to to this j insert a blank line, merge the cell from column 2 to 5 and display the text.

What j have can be

123456 Cola      2 8 2.16

524895 Orange 2 8 2.16

542694 Sprite   2 8 2.16

Now j point the cursor to orange row and insert a comment as 'For Albert' with colums 2-5 merged.

But in order to get this

123456 Cola      2 8 2.16

524895 Orange 2 8 2.16

For Albert

542694 Sprite   2 8 2.16

J get

123456 Cola      2 8 2.16

For Albert

524895 Orange 2 8 2.16

542694 Sprite   2 8 2.16

Here the questions!!!

There's a way to exclude from sorting some rows and allow the sorting, of course in all grid but , only to that rows between the merged rows if any ?

for example start as

123456 Cola      2 8 2.16

524895 Orange 2 8 2.16

542694 Sprite   2 8 2.16

Insert comment below orange

123456 Cola      2 8 2.16

524895 Orange 2 8 2.16

For Albert

542694 Sprite   2 8 2.16

Point to sprite row and insert cola for albert, sort an get.

123456 Cola      2 8 2.16

524895 Orange 2 8 2.16

For Albert

123456 Cola      2 8 2.16

542694 Sprite   2 8 2.16

The sort is applied for rows 1-2 and 4-5, row 3 ignored because merged.

Thank's for your help

Best regard

Daniele

You can sort a subrange of rows with

grid.QuickSort(column,fromrow, torow);

Column is the column to perform the compare on and this will only sort with range of rows fromrow / torow. So, you can call grid.QuickSort for any range of rows between your merged rows.

Good Aternoon Bruno,

thank's for your reply, on monday j will use that.

Good week end

Best regard

Daniele