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.

InvalidCastException with new version 4.2

Thread ID:

Created:

Updated:

Platform:

Replies:

46840 Jul 21,2006 11:30 AM Jul 26,2006 11:53 AM Windows Forms 5
loading
Tags: Grouping
Martin Nitschke
Asked On July 21, 2006 11:30 AM

GridRecordRow recRow = modelCellStyle.TableCellIdentity.DisplayElement as GridRecordRow;
Object lineObj = recRow.ParentRecord.GetValue("SourceLine");

recRow.ParentRecord throws the exception

System.InvalidCastException: Specified cast is not valid.
at Syncfusion.Windows.Forms.Grid.Grouping.GridRecordRow.get_ParentRecord()
at Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl.OnTableControlCurrentCellActivated(GridTableControlEventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridControlBaseEventsTarget.OnCurrentCellActivated(EventArgs e)
at Syncfusion.Windows.Forms.Grid.GridControlBase.OnCurrentCellActivated(EventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnCurrentCellActivated(EventArgs e)
at Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCurrentCellActivated()
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.Activate(Int32 rowIndex, Int32 colIndex, GridSetCurrentCellOptions options)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.MoveTo(Int32 rowIndex, Int32 colIndex, GridSetCurrentCellOptions options, Boolean discardChanges)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.MoveTo(Int32 rowIndex, Int32 colIndex, GridSetCurrentCellOptions options)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.Table_CurrentRecordContextChange(Object sender, CurrentRecordContextChangeEventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.OnCurrentRecordContextChange(CurrentRecordContextChangeEventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.Syncfusion.Grouping.ITableEventsTarget.OnCurrentRecordContextChange(CurrentRecordContextChangeEventArgs e)
at Syncfusion.Grouping.TableDescriptor.Syncfusion.Grouping.ITableEventsTarget.OnCurrentRecordContextChange(CurrentRecordContextChangeEventArgs e)
at Syncfusion.Grouping.Table.OnCurrentRecordContextChange(CurrentRecordContextChangeEventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableBase.OnCurrentRecordContextChange(CurrentRecordContextChangeEventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.OnCurrentRecordContextChange(CurrentRecordContextChangeEventArgs e)
at Syncfusion.Grouping.Table.NotifyEnterRecordComplete(Boolean success)
at Syncfusion.Grouping.CurrentRecordManager.EnterRecord(Element record)
at Syncfusion.Grouping.CurrentRecordManager.NavigateTo(Element record, Boolean cancelEditIfNotValid, Boolean scrollInView)
at Syncfusion.Grouping.CurrentRecordManager.NavigateTo(Record record)
at Syncfusion.Grouping.Record.SetCurrent()
at Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()

Scott Mercer
Replied On July 21, 2006 03:39 PM

I wanted to add that this exception was not thrown in version 4.1.0.63, which was our previously installed version of Syncfusion Essential Studio.

--Scott

Administrator [Syncfusion]
Replied On July 24, 2006 05:28 AM

Hi,

Sorry for the inconvenience. The sample works fine for me, and I am not able to see the mentioned issue here. I have attached the sample here. Can you able to see the issue in the attached sample? Or can you please tell me how to reproduce the issue in the attached sample so that we can get back soon with a solution at the earliest.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/DeleteRecords_ac8d47f8.zip

Regards,
Haneef

Martin Nitschke
Replied On July 25, 2006 11:31 AM

Hi,

I used the ACC sample database, you may have to change the connection string. If you run the app, you will get the exception right away.

In my real app, I have the ShowNewRecordBeforeDetails set to true. When I go to click any cell, that particular row activates first and thus it throws an exception.

The purpose of the code I have attached is to show you the exception that is happening.

>Hi,

Sorry for the inconvenience. The sample works fine for me, and I am not able to see the mentioned issue here. I have attached the sample here. Can you able to see the issue in the attached sample? Or can you please tell me how to reproduce the issue in the attached sample so that we can get back soon with a solution at the earliest.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/DeleteRecords_ac8d47f8.zip

Regards,
Haneef


GroupingGridSample0.zip

Administrator [Syncfusion]
Replied On July 26, 2006 05:06 AM

Hi Martin,

Try this code snippet to resolve this issue. Please find the code snippet below.

Element el = modelCellStyle.TableCellIdentity.DisplayElement;
GridRecord parent = el.ParentRecord as GridRecord;
if( parent != null )
{
Console.WriteLine(parent);
}

Here is a modified sample.
http://www.syncfusion.com/Support/user/uploads/GroupingGridSample_65760474.zip

Let me know if this helps.
Best Regards,
Haneef

Martin Nitschke
Replied On July 26, 2006 11:53 AM

Yes, it works. The "new row" cell gets activated first, and that doesn''t contain the parent record. After I do the null check, the row I clicked on is activated and it has a parent record so the code works. In previous versions, my code worked. I believe the "new row" was not getting activated first, though I don''t know for sure. For right now this works, but maybe it is a bug in the code that you can look into so this event isn''t firing twice.

Thanks,
Martin

>Hi Martin,

Try this code snippet to resolve this issue. Please find the code snippet below.

Element el = modelCellStyle.TableCellIdentity.DisplayElement;
GridRecord parent = el.ParentRecord as GridRecord;
if( parent != null )
{
Console.WriteLine(parent);
}

Here is a modified sample.
http://www.syncfusion.com/Support/user/uploads/GroupingGridSample_65760474.zip

Let me know if this helps.
Best Regards,
Haneef

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.

;