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

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

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!

3 Replies

RC Rajadurai C Syncfusion Team April 6, 2010 09:38 AM UTC

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


ZW Zhigang WANG April 12, 2010 08:50 AM UTC

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


RC Rajadurai C Syncfusion Team April 15, 2010 05:44 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon