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
close icon

issue in GridQueryCellInfoEventHandler

Dear Syncfusion Team,

I've an issue in grid while getting row index in GridQueryCellInfoEventHandler. While scrolling down the data grid i get right row index in increasing order but at some point i got wrong index value. Let during the scroling i am 506th row position and scrolling further it turns to unexpected value like 2 or 5 etc. It happens at some random point.Futher scrolling it returns right index.

Please provide some work around regarding this issue asap.

thanks
arvind

9 Replies

LS Lingaraj S Syncfusion Team September 2, 2009 01:07 PM UTC

Hi Arvind,

Thank you for your interest in Syncfusion products.

I am afraid that I am unable to reproduce the issue in GridQueryCellInfoEventHandler, when the RowIndex get from the GridQueryCellInfoEventArgs.

I have created a simple sample to test this issue and it is available in the following link.
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/Forums/F89652.zip

Please refer the following steps which I tried,

1. Run the Application.
2. Scroll vertical scroll bar.

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample or send us the reproducing steps so that we could sort out the cause of the issue and provide you a solution?

Regards,
Lingaraj S.


AB Arvind Bhatt September 3, 2009 09:18 AM UTC

Dear Lingaraj S,

Thanks for sample code. I used code sent by you and print row index in concern handler as follows. While scrolling i got e.RowIndex returned in -1. you can see this in snap shot obtained from output. Saome like that is happening in my project causing unexpected behaviour. Plz help. do we need to updated version of this grid ?



void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
System.Diagnostics.Debug.WriteLine("----");
System.Diagnostics.Debug.WriteLine (e.RowIndex.ToString());
if (e.ColIndex == 1&&e.RowIndex>0)
{
e.Style.Text = e.RowIndex.ToString();
}
}

// out put

output.txt attached.



Output_1111999d.zip


AB Arvind Bhatt September 3, 2009 12:28 PM UTC

Dear Lingaraj S,

In my further analysis i noticed that at the time when GridQueryCellInfoEventHandler returns e.RowIndex an unexpected value then at the same time ((Syncfusion.Windows.Forms.Grid.GridControl)ctrl.GridCells.control).TopRowIndex returns right row index where scroll thumb is present. But i'm unable to get this value.

1. Can you plz let me know how can i access this value because it is returning right row index even if GridQueryCellInfoEventHandler returning wrong index.

2. Is there any method except GridQueryCellInfoEventHandler in the grid so that i can find current row index while scrolling (where scroll thumb is present)?

there is release of my project and it is very crucial for us. Plz provide some solution asap.

-arvind


LS Lingaraj S Syncfusion Team September 4, 2009 02:13 PM UTC

Hi Arvind,

Thank you for the update.

1.The QueryCellInfo event is triggered to update the cells in GridControl. When the scrolling is performed in GridControl to update the cells, It will randomly come to update the Cells in QueryCellStyleInfo, so the row index will be random. Please try using QueryCellInfo event row Index to get the value.

2. If you want to get scrollable range, then please try using ScrollCellsRange property in LayoutChanged event to get a viewed range in GridControl.

this.gridControl1.ViewLayout.LayoutChanged += new EventHandler(ViewLayout_LayoutChanged);
void ViewLayout_LayoutChanged(object sender, EventArgs e)
{
GridRangeInfo ran=this.gridControl1.ViewLayout.ScrollCellsRange;
// please Iterate the Range to get a cell
}


3. Please try using Text/Cell Value property in GridStyleInfo to get a value of the cell.

string val=this.gridControl[row,col].Text;


Please let me know if you have any queries.

Regards,
Lingaraj S.


AB Arvind Bhatt September 7, 2009 11:28 AM UTC

Dear Lingaraj S,

Thanks for your valuable suggestion. Now i found the actual cause of the problem. Actually during the scrolling index increases as scroll down and this is expected behavior. In this case OnQueryCellInfo handler called for every cell in the grid view area. But during this functionality if focused row is set in between 0-249 then some times OnQueryCellInfo handler called for this focused row it self and this causes the change of existing row index with this focused row index. Suppose initially focused row is 2 and after scrolling down we are at row index 250. If focused row fires OnQueryCellInfo event then it'll will set new row index to 2 and SlideDataSetWindow will set the dataset cache to initial range 0-249 for this new index and hence graph displayed accordingly.

To regenerate please do following steps.

1. Open the project in Visual Studio and run in debug mode.
2. On main form click on Row 2 and start scrolling down.
3. Analyze the Output window in debug mode.
4. Search for test2 in output window.
5. You will see indexes increases as scroll down but it set to index 2 at some irregular intervals.

Same sample code is attched with little bit modification in gridControl1_QueryCellInfo handler.

PLEASE LET ME KNOW THE REMEADY OF THIS ISSUE ASAP BECAUSE IT IS CAUSING UNEXPECTED DISPLAY OF DATA FOR SOME INTERVAL.

- arvind





F89652_eaa0c7a1.zip


LS Lingaraj S Syncfusion Team September 8, 2009 02:51 PM UTC

Hi Arvind,

Thank you for the update.

To be more clear the QueryCellInfo event is only triggered by the grid for a particular cell, whenever the cell infomation is needed by GridControl. So it’s not mandatory that grid triggers the QueryCellInfo for all the cells when scrolling is performed.

It’s better to choose the appropriate event according to the requirement. Please go through the online documentation from the below link and Please feel free to get back to us if you need further assistance on this.

http://help.syncfusion.com/ug_73/gridwin/default.html

Regards,
Lingaraj S.


AB Arvind Bhatt September 9, 2009 04:20 AM UTC

Dear Syncfusion team,

My simple question is that if focused row is 2 Then during the scrolling why focused row fires QueryCellInfo event randomly for row index 2. This is the main problem what we are facing. Please go through the sample sent in previous mail and follow the steps to regenerate the issue.

Is there any way to stop firing QueryCellInfo event by focused row if it is not in visible area of the grid.

-arvind


LS Lingaraj S Syncfusion Team September 10, 2009 02:39 PM UTC

Hi Arvind,

Thank you for the update.

Please try using CustomGridControl to prevent the QueryCellStyleInfo event being fired when the cell not visible in the GridControl.

Please refer the code below:

public class MyGrid : GridControl
{
protected override void OnQueryCellInfo(GridQueryCellInfoEventArgs e)
{
GridRangeInfo ran = GridRangeInfo.Cell(e.RowIndex, e.ColIndex);
bool cellvisible=false;
if(this.ViewLayout.ScrollCellsRange.Contains(ran))
cellvisible=true;
if(cellvisible)
base.OnQueryCellInfo(e);
}
}


Please let me know if you have any queries.

Regards,
Lingaraj S.


AB Arvind Bhatt September 11, 2009 08:16 AM UTC

Dear Lingaraj S,

Thanks for your help.
Code snippet given by you falshes a new idea in my mind. Hope may i'll resolve my problem.

Thanks again.

-arvind

Loader.
Live Chat Icon For mobile
Up arrow icon