You can change the font of the cell where the text flows as follows
private void gvView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column != null && e.Column.Name == bgcStav.Name)
{
float minFontSize = 6;
string text = "teeeeeeeeeeeeeext";
int minWidth = gvView.CalcColumnBestWidth(bgcStav);
SizeF s = e.Appearance.CalcTextSize(e.Graphics, text, minWidth);
if (s.Width >= minWidth)
{
e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, minFontSize);
}
}
}
but it is much better to trim the text if it overflows (you do not know how long the text can be), when you do not want to use wordwrap
private void gvView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column != null && e.Column.Name == bgcStav.Name)
{
string text = e.DisplayText;
string newText = "";
int maxWidth = e.Bounds.Width - 20;
SizeF textSize =e.Graphics.MeasureString(text, e.Appearance.Font);
if (textSize.Width >= maxWidth)
{
string textPom = "";
for (int i = 0; i < text.Length; i++)
{
textPom = text.Substring(0, i) + "...";
textSize = e.Graphics.MeasureString(textPom, e.Appearance.Font);
if (textSize.Width >= maxWidth)
{
newText = text.Substring(0, i - 1) + "...";
break;
}
}
e.DisplayText = newText;
}
}
}
Advantage of this solution is that the crop only what is displaied, but in the datatable text remains in its original form