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
close icon

Painting my own text

Please see the attached Sample. I am overriding the onPaint event and drawing my own text in cell A1 that overflows into neighboring cells. When I scroll to the right (say column 10) and start to scroll back to the 1st column the text does not paint until I scroll back to column 1. My code that determines the cells to paint in the OnPaint event appears to be using incorrect calls to the SF system to determine which cells to paint and/or my call to get the rectangle might be incorrect as well. Another issue I''ve run into is when the 1st column is not visible and I do a full re-paint (tab to another app and back) then the text from the 1st column shows up in the 2nd column starting at the beginning of the text instead of clipping. Please Advise. Thanks, Steve

12 Replies

ST Steve January 13, 2005 11:02 AM UTC

I''ve also noticed that the same occurs when I attempt to fill in my own background color in cells during the onPaint event. Steve


AD Administrator Syncfusion Team January 13, 2005 01:59 PM UTC

I am not sure you will be able to get this to work without writing a lot of code. Your code gets its text from a visible cell. In your sample, column 1 is the only cell that has text set in it. So, when col 1 is not visible, style.Text is always empty. This would explain the text not showing as you scroll back to col 1. Is there some reason you are not just using our floating cells support, or banneredranges or coveredranges to display information over several cells.


ST Steve January 13, 2005 07:17 PM UTC

I am doing my own drawing for a number of reasons, but the major reason(s) is to use GDI, cell indentions and my own images in a cell. I could probably use the CellDraw event, but I have issues adjusting the overflow when I manually indent text for a image. Please see the attached example. When I simply draw text in a cell the overflow is fine, but when I manually adjust the rectangle to make room for the bitmap my overflow is incorrect. Is there some way I can adjust the overflow in querycell or some other event? Run the example and press the button and you will notice the overflow issue. Thanks, Steve SFOverFlow_818.zip


AD Administrator Syncfusion Team January 13, 2005 08:25 PM UTC

Try shrinking the rect'' width by the amount you indent the text. if (blnDrawImage && e.ColIndex == 1) { int offSet = rect.X; rect.X +=20; e.Graphics.DrawImage(this.imageList1.Images[0],rect.X,rect.Y); rect.X += this.imageList1.Images[0].Width + 1; offSet = rect.X - offSet; rect.Width -= offSet; }


AD Administrator Syncfusion Team January 14, 2005 01:18 PM UTC

As I suspected, shrinking the rectangle does fix the immediate issue, but if you scroll to the far right and then scroll back you will notice that the overflow is not correct and that the beginning of the text is actually shown twice. I attempted to attach a zip file, but the browser interface did not update the incident with the file location so I have sent you the file. Although it''s not an option I played with the DisableScrollWindow flag and it didn''t make a difference either. Thanks, Steve


AD Administrator Syncfusion Team January 14, 2005 01:23 PM UTC

Sent email to support with bitmap. Thanks, Steve


AD Administrator Syncfusion Team January 14, 2005 03:38 PM UTC

I think you will want to set DisableScrollWindow = true. Also, I think you need to get the floated rectangle, and not the cell rectangle. //old code //rect = this.gridControl1.RangeInfoToRectangle(GridRangeInfo.Cell(e.RowIndex,e.ColIndex),GridRangeOptions.MergeFloatedCells | GridRangeOptions.MergeCoveredCells); //new code rect = this.gridControl1.RangeInfoToRectangle(this.gridControl1.FloatingCells.FindRange(e.RowIndex, e.ColIndex));


ST Steve January 14, 2005 05:44 PM UTC

I did just as you suggested but the text in cell C1 is no longer appearing. The text in A1 does appear to be correct. If a cell does not float, then the FloatingCells.FindRange returns nothing. Is there not a quick call to get the rectangle that regardless if it''s floating, merged or not. I also tried DisableScrollWindow, but it did not make a difference and as I stated earlier it''s not an option for us to turn this off as the performance issue is not acceptable. Thanks, Steve


AD Administrator Syncfusion Team January 14, 2005 09:59 PM UTC

If rect comes back empty from that call, you can get the cell rect at that point.
rect = this.gridControl1.RangeInfoToRectangle(this.gridControl1.FloatingCells.FindRange(e.RowIndex, e.ColIndex));
if(rect.IsEmpty)
	rect = this.gridControl1.RangeInfoToRectangle(GridRangeInfo.Cell(e.RowIndex,e.ColIndex),GridRangeOptions.MergeFloatedCells | GridRangeOptions.MergeCoveredCells);


ST Steve January 17, 2005 11:22 AM UTC

Thanks Clay. Going back to the issue of overflowing into neighboring cells, I have implemented your suggestion in the attached example in which I am "shrinking" the rectangle by the amount of indent. The issue is that when you adjust this rectangle and there is nothing to the right then the overflow should occur, but is not as the rectangle is adjusted. Run the exe in the attached example, and you will notice that the last word does not paint unless you remove the image indent by pressing the "place image in cell button." What I need is some way to adjust the rectangle so Syncfusion knows to further overflow the text. Thanks for your help in these issues. Steve SFOverFlow2_9928.zip


ST Steve January 21, 2005 11:06 AM UTC

Any update to this last issue?


AD Administrator Syncfusion Team January 21, 2005 11:28 AM UTC

Instead of just immediately adding the offset to the rectangle, you will have to increment the rectangle''s width a column width at the time, until either you hit an occupied column (and hence floating is not allowed), or you have increased the rectangle width by the desired offset. I think you can use rng.Right (or probably rng.Right+1) to get the first column you need to check to see if it is occupied.

Loader.
Live Chat Icon For mobile
Up arrow icon