Is this a bug in the sample app ? DataGridView Default Error Dialog

Is this a bug in the sample app ? DataGridView Default Error Dialog

Old forum URL: forums.lhotka.net/forums/t/186.aspx


mensand posted on Wednesday, May 24, 2006

Hi all,

I've bought the book (C# version at bookpool.com) and was impressed as soon as i got reading it. Great work. When i downloaded the code from this site i was trying to play a bit with it but got stuck with the following.

The following exceptions (see lowest part of this post) i get when i run the sample windowsforms tracker.

What i do is login as "power" and then open the projects for edit.

project "Expert C# Business Objects"

Select one resource. "Jefferson Thomas"

change the lastname to "Jefferson TEST" press the apply button and then the exception are raised over and over again when you move the mouse over the grid.

What i'm doing wrong ? Or is it a bug ?

I think i found the problem maker in ResourceEdit.cs I've added 1 line of code. And marked it green

private void SaveResource(bool rebind)

{

using (StatusBusy busy = new StatusBusy("Saving..."))

{

// stop the flow of events

this.ResourceBindingSource.RaiseListChangedEvents = false;

this.AssignmentsBindingSource.RaiseListChangedEvents = false;

// do the save

Resource temp = Resource.Clone();

temp.ApplyEdit();

try

{

_resource = temp.Save();

_resource.BeginEdit();

if (rebind)

{

// rebind the UI

this.ResourceBindingSource.DataSource = null;
this.AssignmentsBindingSource.DataSource = null;
this.ResourceBindingSource.DataSource = _resource;
/
/Added the line below
this.AssignmentsBindingSource.DataSource = _resource.Assignments;

ApplyAuthorizationRules();

}

}

 

 

Greetings Andre Mens

 

 

 

---------------------------
DataGridView Default Error Dialog
---------------------------
The following exception occurred in the DataGridView:

 

System.IndexOutOfRangeException: Index 0 does not have a value.

   at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)

   at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(Int32 rowIndex)

 

To replace this default dialog please handle the DataError event.
---------------------------
OK  
---------------------------

RockfordLhotka replied on Wednesday, May 24, 2006

There is errata regarding the rebinding code regarding this issue.

mensand replied on Wednesday, May 24, 2006

Hi Rocky

You're correct in this. Only the erata you're talking about is already fixed in the version i have the problem i've stumbled on is in a different file ResourceEdit.cs
It looks like the samen coding bug.

Greetings Andre

 

RockfordLhotka replied on Thursday, May 25, 2006

Got it - thanks! I have fixed this now in cvs and it will be part of 2.0.1.

Copyright (c) Marimer LLC