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

Different values (Model - View)

Hi together,

we are using a GGC which is bound to our business logic via databinding (by implementing the BindingList stuff).

Now the underlying data object (MyRow) has a property called "TestDate" of type double:

public class MyRow
{
public double TestDate
{
get;
set;
}
}

This property results in a corresponding column in the GGC called TestDate of type double. Now I want the grid to show "Off" in a cell (of that column) if the value of a TestDate cell becomes "0". How can this be solved. Currently when I try to set the Renderer.ControlText property to "Off" I get an exception because the literal "Off" is not of type double.

It is necessary for us not to change the TestDate property to type string.

Any help would be great.

Cheers,
Tom

4 Replies

HA haneefm Syncfusion Team April 5, 2007 06:03 PM UTC

Hi Tom,

If you just want to display the "Off" text instead of "0" in a grid cell, you can handle the DrawCellDisplayText and set e.DisplayText there to easily control what text is drawn in the cell.

private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex == 3 )
{
if(e.DisplayTex == "0")
e.DisplayTex = "off";
}
}

Best regards,
Haneef


FG Franz Gsell April 10, 2007 10:01 AM UTC

Hi Haneef,

thank you very much for your suggestion. One question about this is, it seems the event "DrawCellDisplayText" is not called if the cell is in edit mode. How can I achieve the same effect while the cell is in edit mode? How can I change the displaytext in edit mode?

Cheers,
Tom


HA haneefm Syncfusion Team April 11, 2007 07:25 PM UTC

Hi Tom,

If you want to display the formatted text in the editing mode then subscribe the QueryCellFormattedText event and set the e.Text to your new formatted value and then set e.Handled to TRUE to cancel it.

this.gridDataBoundGrid1.Model.QueryCellFormattedText +=new GridCellTextEventHandler(Model_QueryCellFormattedText);

private void Model_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
if( e.Value.ToString() == "0" )
{
e.Text = "OFF";
e.Handled = true;
}
}

Best regards,
Haneef


FG Franz Gsell April 12, 2007 11:50 AM UTC

Hi Haneef,

thank you very much - your support is great :-)

Loader.
Live Chat Icon For mobile
Up arrow icon