I have gridview with string, date, and numeric columns. Once I set the data source and fill with data, I format each column to a suitable display - eg: short date, 2 decimal places for some, 4 decimals for others, etc. using the column.formatstring.
On a row click I need to get the formatted cell text, not the value and am wondering how I can do this? Eg: the underlying value of a cell is 12345.670000 but is formatted and displayed in the cell as 12,345.67. I could not find a "cell.text" property; and cell.value gives me the raw data.
How can I get the formatted cell text? Thanks, Brendan
4 Answers, 1 is accepted
0
Hello Brendan,
Thank you for writing.
You can extract the formatted text from the visual cell element. It is necessary to subscribe to the MouseDown event and get the GridDataCellElement under the mouse. Here is demonstrated a sample code snippet:
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Thank you for writing.
You can extract the formatted text from the visual cell element. It is necessary to subscribe to the MouseDown event and get the GridDataCellElement under the mouse. Here is demonstrated a sample code snippet:
private void radGridView1_MouseDown(object sender, MouseEventArgs e){ GridDataCellElement cellElement = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement; if (cellElement != null) { RadMessageBox.Show(cellElement.Text); }}I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.
0
MORDECHAI
Top achievements
Rank 1
answered on 28 Nov 2019, 08:32 PM
Given the `Cell` object without any location data how can I do it?
0
MORDECHAI
Top achievements
Rank 1
answered on 28 Nov 2019, 08:33 PM
I mean
GridViewCellInfo0
Hello,
If you have the data cell object (GridViewCellInfo), you can find the visual cell element and get its Text property:
I hope this information helps.
If you have the data cell object (GridViewCellInfo), you can find the visual cell element and get its Text property:
private void radGridView1_CurrentCellChanged(object sender, CurrentCellChangedEventArgs e)
{
GridViewCellInfo dataCell = e.NewCell;
GridRowElement visualRowElement = this.radGridView1.TableElement.GetRowElement(dataCell.RowInfo);
if (visualRowElement != null && visualRowElement.VisualCells.Count > 0)
{
string formattedText = visualRowElement.VisualCells[dataCell.ColumnInfo.Index].Text;
RadMessageBox.Show(formattedText);
}
}Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
