Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to merge cells horizontally in GridView

$
0
0

This example demonstrates how to merge cells located in the same row. The main idea is to paint merged cell manually.
You can find a helper class in this example, which can be easily connected to your existing GridView.

Question Comments

Added By: John Nyari at: 9/16/2013 9:57:18 AM    

Hi - all leads for horizontal merging seem to lead here. I have integrated it and found it works very well. However I seem to get a crash if the cells its merging are cells that have already been merged vertically. I am running v2012 12.2.8. Thanks

Added By: Maxim (DevExpress Support) at: 9/16/2013 11:32:16 PM    

Hello John,

I have opened a separate issue on your behalf:

Application crash when using an approach from the E2472 example and merging cells horizontally

Please refer to this report for further correspondence on this item.

Added By: Chris Janssen 1 at: 12/18/2013 12:17:48 PM    

It also crashes if you merge cells cells that have different types of data in them (merge a cell with an integer and a cell with a string)

Added By: Chris Janssen 1 at: 12/18/2013 12:30:39 PM    

After more testing It seems to crash because of an infinite loop.

        If _view.GetRowCellValue(rowHandle, column) isNot value Then
            _view.SetRowCellValue(rowHandle, column, value)
        End If

The above code doesn't work when comparing integers, it always says they're different, so it keeps changing the value and getting called infinitely. When changed to

        If _view.GetRowCellValue(rowHandle, column) <> value Then
            _view.SetRowCellValue(rowHandle, column, value)
        End If

it works.

Added By: HansG at: 1/2/2014 9:30:55 AM    

I think there is an error in addMergedCell:
The desired value of the cell is not put in the mergedCell list. This is, because the AddMergedCell with the integers as parameters does not use the AddMergedCell variant with "value".
To fix this add parameter "value" to the call of AddMergedCell in MyCellMergeHelpler.cs.
This will also fix the view of the strings, that where defined in Form1().

Alternativly don ́t use .absoluteIndex and just use the columns.

Added By: Dan Nordin at: 10/6/2014 7:12:40 PM    

Hi, thanks for this example.  The only problem I have with it is when you convert your grid over OptionsView.AutoColumnWidth = false and then scroll over so that one of the merged columns starts to disappear off the left side of the grid, it ends up covering up the Indicator column.  Likewise if you scroll so the columns start to disappear off the right they end up covering about 1 pixel of the frame of the grid on the right side of the scrollbar (the far side of it).  If this could be remedied in the example that would be a huge help to me because I need to implement this in a big grid with lots of scrolling.  Thanks.

Added By: Demetrius (DevExpress Support) at: 10/7/2014 2:49:26 AM    

Hi Dan,

I need to clarify some details to process your recent post more efficiently. I have created a separate ticket on your behalf: E2472 - Merged cells disappear while scrolling. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>