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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Display when numeric value exceed Cell width

Thread ID:

Created:

Updated:

Platform:

Replies:

70344 Dec 7,2007 03:32 PM UTC Dec 7,2007 11:24 PM UTC WinForms 3
loading
Tags: GridControl
Qingde Shi
Asked On December 7, 2007 03:32 PM UTC

Hi,

I am wondering if there exists a property or a way to display numberic cell value as ##### when the value exceeds cell width (just like the behavior in excel).

Currently, it only shows part of the value which could potentially lead to wrong reading.

BTW, I am using GridControl 5.2

Thanks,

Q


haneefm [Syncfusion]
Replied On December 7, 2007 04:13 PM UTC

Hi Q,

You can do this dynamically in DrawCellDisplayText event. This way you do not modify the actual datatable values, but instead just change what the grid displays. In that event you need to set the e.DisplayText to some new value to want to display. Use the e.RowIndex and e.ColIndex to get the row and column of the cell for which the displaytext has to be set. Below is a code snippet.

private void DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
SizeF siz = e.Graphics.MeasureString(e.Style.CellValue.ToString(), e.Style.GdipFont);
if ((siz.Width + 2) > e.ClipBounds.Width)
{
e.DisplayText = "##############";
}
}
}

Best Regards,
Haneef


Qingde Shi
Replied On December 7, 2007 09:50 PM UTC

Hi Haneef,

Thanks. That works quite well.

one more related question, while setting the DispalyText as #####, how to set CellTipText to show what should have shown the FormattedText.

Do I have to set the CellTipText in QueryCellInfo when in vitual mode?

Thanks,

Q


>Hi Q,

You can do this dynamically in DrawCellDisplayText event. This way you do not modify the actual datatable values, but instead just change what the grid displays. In that event you need to set the e.DisplayText to some new value to want to display. Use the e.RowIndex and e.ColIndex to get the row and column of the cell for which the displaytext has to be set. Below is a code snippet.

private void DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
SizeF siz = e.Graphics.MeasureString(e.Style.CellValue.ToString(), e.Style.GdipFont);
if ((siz.Width + 2) > e.ClipBounds.Width)
{
e.DisplayText = "##############";
}
}
}

Best Regards,
Haneef




haneefm [Syncfusion]
Replied On December 7, 2007 11:24 PM UTC

Hi,

You can set the Style.CellTipText for the grid cell to show the tooltip in a grid. You can do this in QueryCellInfo.

private void grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(e.RowIndex > 0 && e.ColIndex == 3)
{
e.Style.CellTipText = e.Style.FormattedText;
//maybe .Text or some other string...
}
}

Best regards,
Haneef


CONFIRMATION

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.

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

;