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.
Syncfusion Feedback

QueryCellStyleInfo Event

Thread ID:

Created:

Updated:

Platform:

Replies:

58128 Mar 19,2007 05:56 PM UTC Mar 21,2007 02:28 PM UTC Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 19, 2007 05:56 PM UTC

Hi

I am doing some calculation on a column. i.e calculating % for 2 other columns.
I have done this in querycellstyleinfo event but i am getting calculations done for alternate records only. I checked and found that event is fired for alternate rows only i,e if i have 6 records then event is fired only for 3 times
Please can you help me solving this.
This is very urgent
Please help

Thanks
Harshad


Administrator [Syncfusion]
Replied On March 19, 2007 06:55 PM UTC

Hi Harshad,

There is no built-in event for detecting alternate rows in a DataBoundGrid. If you want to detect the alternate rows in a grid, you would have to derive the GridDataBound control and override the OnPrepareViewStyleInfo method to fire the event . Please try the below code and let me know if this helps.

public class MyGridDataBoundGrid : GridDataBoundGrid
{
public delegate void AlternatePrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e);
public event AlternatePrepareViewStyleInfo AlternateRowPrepareViewStyle;

public MyGridDataBoundGrid(){}

protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
if( AlternateRowPrepareViewStyle != null)
{
if( e.RowIndex % 2 == 0 )
AlternateRowPrepareViewStyle(this,e);
}
base.OnPrepareViewStyleInfo (e);
}
}

//Create instance of the MyGridDataBoundGrid and subscribe the AlternateRowPrepareViewStyleInfo event.
this.gridDataBoundGrid1 = new MyGridDataBoundGrid();
this.gridDataBoundGrid1.AlternateRowPrepareViewStyle +=new AlternatePrepareViewStyleInfo(gridDataBoundGrid1_AlternateRowPrepareViewStyle);

private void gridDataBoundGrid1_AlternateRowPrepareViewStyle(object sender, GridPrepareViewStyleInfoEventArgs e)
{ e.Style.BackColor = Color.Red; }

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 20, 2007 08:36 AM UTC

I dont want alternate rows....Actually i am facing that problem only.....i want to do the % calculation for each row. I have wriiten code in QueryCellStyleInfo event. But it is calculating for alternate rows only and not for each row.
I am not able to find out the cause of this.
Please tellme where i am doing wrong.

Thanks
Harshad

Administrator [Syncfusion]
Replied On March 20, 2007 09:32 PM UTC

Hi Harshad,

Please try to provide us some more information on this issue. I tried to reproduce the issue, but couldn't. kindly provide us a small sample to reproduce the issue or modify the browser sample accordingly. This will help us to analyse the issue further.

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On March 21, 2007 10:58 AM UTC

Hi,

I got the cause of this problem.
I was checking condition like
e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell

i dont know why but when i put this condition i get the calculations and formating for alternate rows only and not all rows. Why it consider alternate rows as recordfieldcell and not all rows cell..?

Administrator [Syncfusion]
Replied On March 21, 2007 02:28 PM UTC

Hi Harshad,

The reason is that you are checking the RecordFileldCell only. Also you need to check the AlternateRecordFileldCell in a QueryCellStyleInfo event. Please find the code snippet below.

if ( e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell )
{
//code here...
}

Best regards,
Haneef

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

;