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

Drawing Issue in Covered Cell

Hi, I have the following code in the Checked event of a checkbox this.programGridNew.BeginUpdate(); this.programGridNew.Refresh(); this.programGridNew.EndUpdate(); wgich causes all internal events of the grid to be fired. Redrawing of covered cell in header row does not work properly. i have color in the covered cells using the following code in form_load event. GridStyleInfo colStyle = new GridStyleInfo(); colStyle.CellType = "Static"; colStyle.BackColor = Color.BurlyWood; ColStyle.HorizontalAlignment = GridHorizontalAlignment.Center; colStyle.VerticalAlignment = GridVerticalAlignment.Middle; colStyle.CellAppearance = GridCellAppearance.Sunken; colStyle.Font.Size = 7; colStyle.Font.Bold = true; programGridNew.ChangeCells(GridRangeInfo.Cells(0, 1, 0, 25), colStyle); some of the covered cell does not show the color on redrwaing (by checking / unchecking the checkbox) they are simple white. if i minimize the screen and maximize again they are fine. i have attached the code of QueryCoveredRange event. Please help me. thanks covered_8978.zip covered_7903.zip

3 Replies

AD Administrator Syncfusion Team June 8, 2004 03:32 PM UTC

Can you please post a sample project showing the problem? This way I can work directly with what you are trying to do instead of sending you code that works but may not what you are trying to do.


VI VivekS June 8, 2004 05:02 PM UTC

Hi, Please find the attached sample. Please notice the following things: 1. as soon as form is loading and if do scrolling the some of the covered cell at row[0] are not properly drawn. 2. if you check/uncheck any check box the redrawing is very slow very first time. 3. after checking/unchecking the checkbox try scrolloing again some of the covered cells at row[0] are not properly drwan. Please let me know, if i can do anything else. thanks RedrawProj_9901.zip


AD Administrator Syncfusion Team June 8, 2004 05:53 PM UTC

1&3 - One of the lines defining the range for your covered columns was probably not correct.
private void programGridNew_QueryCoveredRange(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventArgs e)
{ 
	if(e.RowIndex == 0 && e.ColIndex > 0)
	{
		if(e.ColIndex % 2 == 1)
		{
			e.Range = GridRangeInfo.Cells(0 ,e.ColIndex,0,e.ColIndex+1);
		}
		else
		{
			//e.Range = GridRangeInfo.Cells(e.ColIndex - 1, 0, e.ColIndex , 0);
			e.Range = GridRangeInfo.Cells(0, e.ColIndex - 1, 0, e.ColIndex ); //changed
		}
		e.Handled = true;
	} //added the else
	else if (totalitemdisplay > 2)
	{
		this.programGridNew.RowCount = 12; 
		if(e.ColIndex == 0 && e.RowIndex > 0)
		{
			if(e.RowIndex % 2 == 1)
			{ //odd row
				e.Range = GridRangeInfo.Cells(e.RowIndex , 0, e.RowIndex + 1, 0);
			}
			else
			{
				//even row
				e.Range = GridRangeInfo.Cells(e.RowIndex - 1, 0, e.RowIndex , 0);
			}
			e.Handled = true;
		}
	}
}
Making the change above seemed to make the scrolling work OK for me. In regard to the speed, any code that you place in PrepareViewStyleInfo should be written as efficiently as possible. In the code, you have a whole series of if statements. They are not organized, and do not use else clauses to skip over blocks of code when possible. For example, you have these three IFs in a row. if (totalitemdisplay == 1 && e.ColIndex%2 == 1) { e.Style.CellValue = e.ColIndex +"."+ e.RowIndex ; } if (totalitemdisplay == 2 && e.ColIndex%2 == 1) { e.Style.CellValue = e.ColIndex +"."+ e.RowIndex ; } if (totalitemdisplay == 2 && e.ColIndex%2 == 0) { e.Style.CellValue = e.ColIndex +"."+ e.RowIndex ; } All three IFs will always be hit. If you used elseif for the last 2 IF''s, then a majority of the time, the last IF would never be encountered. Spending time optimizing the code in PrepareViewStyleInfo will be beneficial.

Loader.
Live Chat Icon For mobile
Up arrow icon