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.
Syncfusion Feedback

Getting Current Record and Column name

Thread ID:

Created:

Updated:

Platform:

Replies:

53183 Dec 10,2006 01:55 PM UTC Aug 19,2008 12:55 PM UTC Windows Forms 7
loading
Tags: Grouping
James Blibo
Asked On December 10, 2006 01:55 PM UTC

I have a ggc that is group by one level.

When I navigative using the ARROW keys or click on a cell using the mouse, I need to determine the current record and the columnname that I am on.

I need to ignore cases where the user click on the plus/minus button, the header cell, or the summarysection.

The only sections that I am interested in is the grid record riow and the caption section row.

Administrator [Syncfusion]
Replied On December 11, 2006 04:57 AM UTC

Hi James,

You can get the current record and current column details from currentcell using the following code.

GridCurrentCell cc = Grid.TableControl.CurrentCell;

//Get the TableCellStyleInfo from GridStyleInfo object
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;

if( style != null && style.TableCellIdentity.Column != null)
{
Element eDisplayElement = style.TableCellIdentity.DisplayElement;
if( eDisplayElement.Kind == DisplayElementKind.Record && eDisplayElement.ParentTable != null )
{
Console.WriteLine("Current Record:" + eDisplayElement.ParentTable.CurrentRecord);
Console.WriteLine("Current ColumnName: " + style.TableCellIdentity.Column.Name);
}
}

Best Regards,
Haneef

James Blibo
Replied On December 11, 2006 04:57 PM UTC

Which event do I subscribe to get this? I want this value as soon at the a cell GETS FOCUS.

Administrator [Syncfusion]
Replied On December 12, 2006 04:35 AM UTC

Hi James,

You can handle the TableControlCellClick event and access the current cell details. Please try the attached sample and let me know if you are looking something different.

GGCCurrentRecordDetails.zip

Best Regards,
Haneef

James Blibo
Replied On December 12, 2006 12:21 PM UTC

This works fine when the user uses the mouse to click in the cell. However, when the you use the arrow key to navigate to the next cell, the event is NOT raised.

I need to determine the current cell for both when a cell receives focus, for both situations!

Administrator [Syncfusion]
Replied On December 13, 2006 06:48 AM UTC

Hi James,

Please try using the TableControlCurrentCellActivated event. This event will be triggered for both the Mouse click and navigation through keys. The following is the code snippet
>>>>>>
//this.gridGroupingControl1.TableControlCurrentCellActivated +=new GridTableControlEventHandler(gridGroupingControl1_TableControlCurrentCellActivated);
private void gridGroupingControl1_TableControlCurrentCellActivated(object sender, GridTableControlEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex,cc.ColIndex] as GridTableCellStyleInfo;
if( style != null && style.TableCellIdentity.Column != null)
{
Element eDisplayElement = style.TableCellIdentity.DisplayElement;
if( eDisplayElement.Kind == DisplayElementKind.Record && eDisplayElement.ParentTable != null )
{
Console.WriteLine("Current Record:" + eDisplayElement.ParentTable.CurrentRecord);
Console.WriteLine("Current ColumnName: " + style.TableCellIdentity.Column.Name);
}
}
}
>>>>>>

Kindly let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan


Administrator [Syncfusion]
Replied On August 18, 2008 05:11 PM UTC

Say, I have saved the CurrentCell, and before completing some processing tried to navigate to another row and even in a different level.
How would I cancel the move to the new Row?
How would I go back to the original cell/row programatically?

>Hi James,

You can get the current record and current column details from currentcell using the following code.

GridCurrentCell cc = Grid.TableControl.CurrentCell;

//Get the TableCellStyleInfo from GridStyleInfo object
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;

if( style != null && style.TableCellIdentity.Column != null)
{
Element eDisplayElement = style.TableCellIdentity.DisplayElement;
if( eDisplayElement.Kind == DisplayElementKind.Record && eDisplayElement.ParentTable != null )
{
Console.WriteLine("Current Record:" + eDisplayElement.ParentTable.CurrentRecord);
Console.WriteLine("Current ColumnName: " + style.TableCellIdentity.Column.Name);
}
}

Best Regards,
Haneef


Sri Rajan [Syncfusion]
Replied On August 19, 2008 12:55 PM UTC

Hi Aaron,

Thank you for your interest in Syncfusion products.

You can use CurrentCell.MoveTo method to move to any cell programatically. You can retain the focus in the current cell by specifying the current row, column index in the MoveTo, so that you can avoid moving to any row until process is completed.

this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(GridRangeInfo.Cell(4, 1));


Please let me know if this helps.

Best Regards,
Srirajan.


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.

Warning Icon 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.Close Icon

;