Home - Forums-.NET - FlyGrid.Net (Windows Forms) - ColumnAlignment, cells draw inconsistent

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

ColumnAlignment, cells draw inconsistent
Link Posted: 19-May-2006 09:23
Hi,

the cells don't draw consistently and alignment is off. Check out the screenshot, in the lower part I added some guidance lines that show that the text in the cells doesn't correctly align:

Link Posted: 19-May-2006 11:05
You've used different fonts (bold font) in custom drawing - check custom drawing code to solve this problem.
Link Posted: 19-May-2006 11:08
the custom drawing code does nothing besides setting a different font or background color (using slighthly modified CoolNode). Also, this problem isn't specific to bold or non bold but also appears within different non-bold cells
Link Posted: 19-May-2006 11:18
here, this is happening in your samples as well (shot taken from Grid Stylizing, Multi Columnar, etc. sample)

Link Posted: 19-May-2006 11:22
here even better prove:

Link Posted: 23-May-2006 08:28
have you found anything on that?
It appears that for some users this is off even more based on their monitor settings
Link Posted: 26-May-2006 09:28
can you please follow up on this and the other topics? thanks, tom
Link Posted: 26-May-2006 11:04
We have done tests, FlyGrid provides corrected rectangles (with same Left and Width props) to draw and used usual Graphics.DrawText. Problem in g.DrawText or incorrect implicit conversion Rectangle to RectangleF.
We'll try to solve this problem to the nearest update.
Link Posted: 26-May-2006 11:12
This code draws text in cell:

StringFormat sf = this.StringFormat;
//specify alignment
sf.Alignment = DrawManager.TranslateAlignment(this.textAlign);
//specify line alignment
sf.LineAlignment = DrawManager.TranslateLineAlignment(this.textAlign);
//specify RTL
if (dci.RightToLeft)
  sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
else
  sf.FormatFlags &= ~StringFormatFlags.DirectionRightToLeft;

//draw
using (Brush foreColorBrush = new SolidBrush(foreColor))
{
  dci.g.DrawString(text, dci.Font, foreColorBrush, (RectangleF)rect, sf);        
}


Try to use this code to draw series of rectangles and you'll receive same problem.
But problem in incorrect work of Graphics.DrawString
Link Posted: 26-May-2006 11:48
We've found solution of this problem - use TrueType fonts instead of raster to draw text more correctly.
Or:
To draw correctly raster fonts needs to be use
Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
To use this mode you can setup this mode in overriden Column.PaintTextInCell:

protected override void PaintTextInCell(CellDrawInfo dci, Brush bkBrush, Color foreColor)
{
  dci.g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  base.protected virtual void PaintTextInCell(dci, bkBrush, foreColor);
}