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.

Retriving Cell Values in GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

70677 Dec 26,2007 06:28 AM Jan 31,2008 04:53 AM Windows Forms 5
loading
Tags: GridControl
Amol Choudhari
Asked On December 26, 2007 06:28 AM


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



Rajagopal [Syncfusion]
Replied On December 26, 2007 07:24 PM

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


Amol Choudhari
Replied On December 27, 2007 01:34 AM

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




Rajagopal [Syncfusion]
Replied On December 27, 2007 07:23 PM

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


Chris Birnbaum
Replied On January 28, 2008 05:44 PM

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


Fathima Shalini P [Syncfusion]
Replied On January 31, 2008 04:53 AM

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



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.

;