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.
Unfortunately, activation email could not send to your email. Please try again.

Different values (Model - View)

Thread ID:

Created:

Updated:

Platform:

Replies:

59142 Apr 5,2007 10:32 AM Apr 12,2007 07:50 AM Windows Forms 4
loading
Tags: GridControl
Franz Gsell
Asked On April 5, 2007 10:32 AM

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

haneefm [Syncfusion]
Replied On April 5, 2007 02:03 PM

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

Franz Gsell
Replied On April 10, 2007 06:01 AM

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

haneefm [Syncfusion]
Replied On April 11, 2007 03:25 PM

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

Franz Gsell
Replied On April 12, 2007 07:50 AM

Hi Haneef,

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

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.

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.

;