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

Currency Cell and ForeColor

Thread ID:

Created:

Updated:

Platform:

Replies:

9919 Jan 16,2004 09:44 AM UTC Jan 17,2004 07:24 PM UTC WinForms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 16, 2004 09:44 AM UTC

I''ve been able to change the Forecolor in a Currency Cell when the Cell Value is different than Zero (using OnDraw). When the Cell Value is Zero the Forecolor does not change. Why? Any ideas or suggestions will be appreciated. TIA, Jose

Administrator [Syncfusion]
Replied On January 16, 2004 02:34 PM UTC

The CurrencyEdit control from our tools (which the grid''s cell control is based on) does have a Zero color property, but this was not exposed in the grid version. We will have to change that. As far as a work around until there is a release that handles this, maybe you can do what you want with PrepareViewStyleInfo.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex > 0 && e.Style.CellType == "Currency")
	{
		double d = 0;
		try
		{
			d = double.Parse(e.Style.Text, e.Style.CurrencyEdit.NumberFormatInfoObject);
		}
		catch{}
		if( d == 0)
		{
			e.Style.CurrencyEdit.PositiveColor = Color.Purple;
		}
	}
}

Administrator [Syncfusion]
Replied On January 16, 2004 04:31 PM UTC

>The CurrencyEdit control from our tools (which the grid''s cell control is based on) does have a Zero color property, but this was not exposed in the grid version. We will have to change that. > >As far as a work around until there is a release that handles this, maybe you can do what you want with PrepareViewStyleInfo. >
>private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
>{
>	if(e.ColIndex > 0 && e.RowIndex > 0 && e.Style.CellType == "Currency")
>	{
>		double d = 0;
>		try
>		{
>			d = double.Parse(e.Style.Text, e.Style.CurrencyEdit.NumberFormatInfoObject);
>		}
>		catch{}
>		if( d == 0)
>		{
>			e.Style.CurrencyEdit.PositiveColor = Color.Purple;
>		}
>	}
>}
>
It did not work like you suggested. Everytime you set a Color either Positive, Negative or ForeColor there is a call to a SetControlColor() method in Tools.NumberTextBoxBase resetting the ZeroColor propety always to "Color [ControlText]".

Administrator [Syncfusion]
Replied On January 16, 2004 08:03 PM UTC

It seems to work in this sample. What am I missing? CS-Currency_8248.zip

Administrator [Syncfusion]
Replied On January 17, 2004 01:04 PM UTC

Attached is a screen shot, no pink color anywhere. Notice although that I was not able to compile the example. I have to comment these two lines: //gridControl1.VScrollPixel = true; //gridControl1.HScrollPixel = true; I''m using Syncfusion 1.6.1.8 and VS 2003, how about you? currency_4660.zip

Administrator [Syncfusion]
Replied On January 17, 2004 07:24 PM UTC

I am using the 2020 beta which is why you had to remove those two properties. In 2020, I can see the color sepecified in PrepareViewStyleInfo

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

;