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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

CoveredRanges and Merge problems

Thread ID:





35141 Sep 23,2005 03:35 PM UTC Sep 23,2005 10:58 PM UTC WinForms 1
Tags: GridControl
Iain Jolly
Asked On September 23, 2005 03:35 PM UTC

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

Administrator [Syncfusion]
Replied On 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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon