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.

Why can''t get the real data from CurrentCell.Renderer.ControlText

Thread ID:

Created:

Updated:

Platform:

Replies:

93756 Apr 1,2010 06:03 AM Apr 15,2010 01:44 PM ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Zhigang WANG
Asked On April 1, 2010 06:03 AM

Hi,

I got a issue about GridControl as below described,

1)Add a GridControl into a .NET windows form
2)Add event handler for the CurrentCellValidating and CurrentCellControlLostFocus events respectivly, the code as below,

private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
Console.WriteLine("CurrentCellValidating,CurrentCell[{0},{1}]:{2}", this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex, cc.Renderer.ControlText);
}

private void gridControl1_CurrentCellControlLostFocus(object sender, ControlEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
Console.WriteLine("CurrentCellControlLostFocus,CurrentCell[{0},{1}]:{2}", this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex, cc.Renderer.ControlText);
Console.WriteLine("CurrentCellControlLostFocus,e.Control:{0}", e.Control.Text);
}

When i input a value, such as "123" in any cell and press 'Enter', i got following output,

CurrentCellValidating,CurrentCell[4,2]:123
CurrentCellControlLostFocus,CurrentCell[4,2]:
CurrentCellControlLostFocus,e.Control:123

My question is,
Why i can't get the value from CurrentCell.Renderer.ControlText in CurrentCellControlLostFocus eventhandler? the value can be got correcly from the e.Control.Text.

Just like the previous show, the current cell still has a 4 index for row and 2 index for column as same as in CurrentCellValidating eventhandle write out.

Is it a defect? or client must use e.Control replace the CurrentCell to get value?

Thanks a lot!

Rajadurai C [Syncfusion]
Replied On April 6, 2010 05:38 AM

Hi Zhigang,

Thanks for your interest in Syncfusion Products.

The reported behavior is not a defect.

CurrentCellControlLostFocus event get triggerred when a cell is about to lose focus. When this event get triggerred, the values of the renderer get cleared as the focus is in the process of MoveTo where it was aware of its target cell.

Hence in this event, you can use either e.Control.Text or either of the following two code settings, to retrieve the current cell value.

cc.Renderer.StyleInfo.CellValue
(or)
cc.Renderer.StyleInfo.Text


Regards,
Rajadurai

Zhigang WANG
Replied On April 12, 2010 04:50 AM

Hi,Rajadurai

Thank you very much and Your descriptions are very concrete.
but seems cc.Renderer.ControlText can get the real value sometimes in our project, sorry for that i can't paste those code in here. the same scenario can't be reproduced in previous sample code.

The version we used in our project is 6.102.0.34.

Those methods you said are work well, Big thanks!

Regards,
Zhigang

Rajadurai C [Syncfusion]
Replied On April 15, 2010 01:44 PM

Hi Zhigang,

Thanks for your update.

The case under which the ControlText property returns value in CurrentCellControlLostFocus event is, when the cell from which the focus is moved is in edit mode but not modified.

If the cell is in modified state and the focus is moved, then the renderer properties get cleared immediately as said before.

Regards,
Rajadurai

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.

;