We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

CoveredRanges and Merge problems

Hi, I am going round in circles trying to represent a specific structure within a datagrid and colour it as detailed below. The grid needs to look like this (Header top and then rows) H1 H2 H3 H4 H5 H6 H7 r1 aa bb cc dd ee ff gg r2 zz xx cc vv bb nn r3 rr tt yy yy yy r4 bb hh jj kk ll qq ww Where in Row 2 and 3 the duplicate row values are not displayed for H1. In row 3 the duplicate row values are not displayed for row 3. I also want to format the rows so that each alternate H1 grouping has an alternate value e.g in the above example Row 1 is white, row 4 black etc. I have attempted to do this within PrepareViewStyleInfo: if(e.ColIndex == 1) { if(e.RowIndex > 1 && this.dgInvoicesMain[e.RowIndex, e.ColIndex].Text == this.dgInvoicesMain[e.RowIndex - 1 , e.ColIndex].Text) { e.Style.Text = ""; } else { _blnColourChanger = ! _blnColourChanger; } } if (e.RowIndex > 0 && e.ColIndex > 0 && _blnColourChanger) { e.Style.BackColor = System.Drawing.SystemColors.ControlLight; } else { e.Style.BackColor = System.Drawing.SystemColors.ControlLightLight; } This will merge the row values for column 1 and I can duplicate this for Column 2,3 etc. I can''t seem to alternate the colours within the grid for the format detailed above e.g. Row 1 is black and Row 4 is white (As row 4 is the next repeating H1 value). It does this on the initial load but if you use the scroll bars it fails. Thanks Iain

1 Reply

AD Administrator Syncfusion Team September 23, 2005 10:58 PM UTC

You cannot assume that the cells are being painted in any particular order. You code assumes _blnColourChanger is being set in some kind of alternating order. This will not work. So, in your line, >>if (e.RowIndex > 0 && e.ColIndex > 0 && _blnColourChanger) you will have to replace _blnColourChanger with some logical condition that is completely detertermined by the information passed in through the event args (e.RowIndex, e.ColIndex and e.Style), and does not assume any particular paint order.

Loader.
Live Chat Icon For mobile
Up arrow icon