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.

Format data in the expression field

Thread ID:

Created:

Updated:

Platform:

Replies:

30205 Jun 14,2005 03:51 AM Jun 28,2005 04:03 AM Windows Forms 8
loading
Tags: GridControl
Prathima Venkobachar
Asked On June 14, 2005 03:51 AM

Hi, 1.How can we format the data in the expression fileds added in the gridgroupingcontrol..? I want to restrict the value to 3 decimal place. 2.I am using this event. this.gridgroupingcontrol.SyncfusionGridControl.SourceListListChanged +=new TableListChangedEventHandler(gridgroupingControl_ListChangedEventHandler); I have a chkbox column. On this event I want to know whether this chkbox is chcked or not.. How can I do this..? Thanks, Prathima

Administrator [Syncfusion]
Replied On June 14, 2005 04:28 AM

1) You need to set the system type of the expression field when you create it, and also set the Format property on its style. ExpressionFieldDescriptor fd = new ExpressionFieldDescriptor("Cost", "[Price] * [Quantity]", typeof(double)); this.grid.TableDescriptor.ExpressionFields.Add(fd); GridStyleInfo style = this.grid.TableDescriptor.Columns["Cost"].Appearance.AnyRecordFieldCell;; style.BackColor = Color.LightGoldenrodYellow; style.CellType = "Static"; style.HorizontalAlignment = GridHorizontalAlignment.Right; style.Format ="#.000"; 2) You can try code like:
if(e.Table.CurrentRecord != null)
{
	Console.WriteLine(e.Table.CurrentRecord.GetValue("CheckBoxCol"));
}

Prathima Venkobachar
Replied On June 14, 2005 06:33 AM

Thnaks for the reply. It works fine. Prathima

Catinat Velmourougan
Replied On June 14, 2005 09:56 AM

hi I tried the same but it didnt work for negative values thanx catinat

Administrator [Syncfusion]
Replied On June 14, 2005 10:12 AM

It seems to work for me in this sample. http://www.syncfusion.com/Support/user/uploads/GGC_ExpressionCOl_994e6894.zip Can you modify the sample to show the problem?

Catinat Velmourougan
Replied On June 21, 2005 08:14 AM

hi I was able to format the negative values to 3 decimal places.Thanx. Now I have a new requirement , I want to change the color of display based on the value. For eg., If the expression field evaluates to a negative value it should be shown as red else it should be black. How to do it?

Administrator [Syncfusion]
Replied On June 21, 2005 10:34 AM

You can use the TableControlPrepareViewStyleInfo event to manage this.
private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
	GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
	if(style != null && style.TableCellIdentity.Column != null
		&& style.TableCellIdentity.Column.Name == "Col2"
		&& (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
		|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell))
	{
		int val = (int) style.CellValue;
		if(val < 0)
			style.TextColor = Color.Red;
	}
}

Catinat Velmourougan
Replied On June 28, 2005 01:30 AM

hi 1. This one involves an evnt. I just want it to be called by a method thro code. 2.I had set style information for every fielddescriptor.Then based on the value I change the style of each and every cell.But still my fielddescriptor style information overrides the cellstyle info I have attached the code. temp_5905.zip

Administrator [Syncfusion]
Replied On June 28, 2005 04:03 AM

You will have to use an event like TableControlPrepareViewStyleInfo to do this in a GridGroupingControl. The reason is that there is no cell specific storage allocated in a GridGroupingControl. If you absolutely need to have cell specific storage (so you can set cell specific style properties), then you will need to use a GridControl. Now you can add cell specific storage to make it seem like you are just setting cell properties in a GridGroupingControl. But under the covers you still have to handle an event (QueryCellStyleInfo) to actually apply the styles when the certain cell is requested. Take a look at this sample. \Syncfusion\Essential Studio\3.2.1.0\Windows\Grid.Windows\Samples\Grouping\EmployeeViewXmlIO

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.

;