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

Retriving Cell Values in GridControl


Hi
I am working with syfunfucion gridcontrol.

While assigning values to the cell I am using following statement
grdStoreGrades[e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex].Text = value;

and in QueryCellInfo I am trying to fetch it using either of
e.Style.Text
or
string columnValue = grdStoreGrades[e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex].Text;

but getting following error:
Recursive call detected. When accessing grid cell objects from a QueryCellInfo event handler make sure you do not recursively access the same cell.


Please help,
Amol CHoudhari



5 Replies

RA Rajagopal Syncfusion Team December 27, 2007 12:24 AM UTC

Hi Amol,

The QueryCellInfo event is hit anytime the grid needs a cell style for any reason. When you use code like grid.Model[row,col].Text inside the QueryCellInfo event, then this will lead to a recursive call. The reason is that, using grid.Model[row, col] will call the QueryCellInfo. So, this needs to be avoided.

To check for cellvalues inside the QueryCellInfo event, you need to check for the row and column index of the cell using e.RowIndex and e.ColIndex and then use the e.Style.Text/e.Style.CellValue to retrieve the cellvalue for the respective cell.

Let us know if you need any further information.

Regards,
Rajagopal



AC Amol Choudhari December 27, 2007 06:34 AM UTC

Hi

Even using e.Style.Text / e.Style.CellValue
I am not able to access Cell Value.

Each times e.Style.Text / e.Style.CellValue
contains the blank( "") values.

Please help regarding the same.

Thanks,
Amol Choudhari

>Hi Amol,

The QueryCellInfo event is hit anytime the grid needs a cell style for any reason. When you use code like grid.Model[row,col].Text inside the QueryCellInfo event, then this will lead to a recursive call. The reason is that, using grid.Model[row, col] will call the QueryCellInfo. So, this needs to be avoided.

To check for cellvalues inside the QueryCellInfo event, you need to check for the row and column index of the cell using e.RowIndex and e.ColIndex and then use the e.Style.Text/e.Style.CellValue to retrieve the cellvalue for the respective cell.

Let us know if you need any further information.

Regards,
Rajagopal





RA Rajagopal Syncfusion Team December 28, 2007 12:23 AM UTC

Hi Amol,

You will be able to access the cellvalue of a cell in the QueryCellInfo event if you are using the GridControl in the virtual mode(Virtual grid). This is because the value has to be queried in this event before it can be accessed.

Please refer to the following shipped samples to know more about virtual grid
\\Syncfusion\EssentialStudio\6.1.0.34\Windows\Grid.Windows\Samples\2.0\VirtualGrid\VirtualGridTutorial\

For the plain GridControl, acessing the e.Style.Text/CellValue wont work, I will analyze more on this reagard and let you know. You can try the PrepareViewStyleInfo event of the GridControl to retrieve the cellvalue using e.Style.CellValue.

Regards,
Rajagopal



CB Chris Birnbaum January 28, 2008 10:44 PM UTC

Hi guys,

I had the same problem (CellValue is an empty string) and the workaround I got from DirectTrac is to do something like the following:

GridControl grid = (GridControl)sender;

GridStyleInfoStore data =
grid.Data[e.RowIndex, e.ColIndex] as
GridStyleInfoStore;

if (data != null)
{
GridStyleInfo style =
new GridStyleInfo(data);
MyType val = style.CellValue as MyType;
if (val != null)
{
e.Style.Text = val.Name;
}
}

HTH,

Chris



FS Fathima Shalini P Syncfusion Team January 31, 2008 09:53 AM UTC

Hi Amol,

We regret for the delay in responding you.

It is possible to get the cellvalue of gridcell in QueryCellInfo event by using the GridData. The GridData returns a StyleInfoStore. We need to create an instance of a GridStyleInfo to get access to all the style property of the gridcell. Please refer the following code snippet that illustrates this:


private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
GridControl Grid = sender as GridControl;
GridStyleInfoStore data = Grid.Data[e.RowIndex, e.ColIndex] as GridStyleInfoStore;
if (data != null)
{
GridStyleInfo style = new GridStyleInfo(data);
MyType mytype = style.CellValue as MyType;
if (mytype != null)
{
e.Style.Text = mytype.Name;
}
}
Console.WriteLine("xxx" + e.Style.Text);
}
}


Please find the simple sample in the following link:

http://websamples.syncfusion.com/samples/Tools.Windows/F70677/main.htm

Please let me know if any concerns.

Regards,
Fathima



Loader.
Live Chat Icon For mobile
Up arrow icon