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

appending a string to a numeric value in gridboundgrid

How do we do this with gridboundgrid. http://support.microsoft.com/default.aspx?scid=kb;en-us;318581 Basically, i want to intercept the value coming from the datasource, do some processing, then display a new value. Thanks Trevor

3 Replies

AD Administrator Syncfusion Team January 5, 2006 04:08 PM UTC

Hi Trevor, you can use DrawDisplayText Event for appending a string with a numeric value. Here is the code snippet. private void gridDataBoundGrid1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e) { if(e.Style.CellIdentity.ColIndex == 1 && e.Style.CellIdentity.RowIndex > 0) e.DisplayText = "$" + e.DisplayText; } Refer to sample for more details. Let me know, if you need futher assistance. Regards, Madhan.

GridTextBoxColumnDemo.zip


TM Trevor Moody January 5, 2006 06:03 PM UTC

What i actually want to do is take the data coming from the column in the data source, use this data as a key for a lookup in a hashtable, then display the corresponding value from the Hashtable. Is this event a suitable place to do this? Thanks Trevor


AD Administrator Syncfusion Team January 6, 2006 03:12 PM UTC

Hi Trevor, To format the Cell Text ,you need to handle either QueryCellFormattedText Eventhandler/ DrawCellDisplayText Event Handler. Refer to modified sample for more details For DrawCellDisplayText Event Handle: private void gridDataBoundGrid1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e) { GridModel model = this.gridDataBoundGrid1.Model; if(e.Style.CellIdentity.RowIndex > 0 && e.Style.CellIdentity.ColIndex == 1) { int keyColIndex = model.NameToColIndex("ParentID"); string key = model[e.Style.CellIdentity.RowIndex, keyColIndex].Text; e.Style.Description = key; if (key != null) { object value = celltable[key]; if (value != null) e.DisplayText = value.ToString()+ e.DisplayText; } } } For QueryCellFormattedText Event Handler: Refer this KB article - http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=333 Let me know if you need futher assistance, Regards, Madhan.

GridTextBoxColumnDemo0.zip

Loader.
Live Chat Icon For mobile
Up arrow icon