Undo and the PictureEdit Control


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I have a PictureEdit control on a maintenance form.  If a user clicks "New", the form responds properly setting up the window to receive the data.  If the same user then clicks undo (even without doing anything else), he gets the following error:

An error occurred while refreshing the data from field 'PartsBOsketch' to property 'EditValue' on control 'SketchPictureEdit.'

I am using SQL Server 2000 (yes, still) and the field is of type 'image'.  The control works absolutely beautifully in all other contexts, except this one.  What do I make of the error?  How do I solve it?

Btw, my custom field properties are set to: Return Alternate on Null; and, the Null Replacement Value is new byte[] {}.

Thanks,
Bill

Replies
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
So yup....it is exactly what I said!  You have to take this into account.  When you call Undo, the DevEx control is still bound and so there is no record when the Refresh is called and updates the binding.  This is not a bug, but rather how the underlying binding of .NET and SF works.  In this case, since you are binding to the PictureEdit, you are going to either:

  1. Take a "no count" BO into account in your strong-typed property
  2. Manually update the control instead of binding.

If you want to see how to properly set this up, download the StrataFlix sample as it shows you this exact scenario with either the MoviesBO or the PeopleBO as they both have images that bind to a PictureBox control.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Thanks, Trent!  You got me thinking on the right track.  Much appreciated.

I fixed the problem by adding, like you suggested, a check on the count of the BO.  I introduced it into some code that I originally did not think would be called since the Undo was clicked; however, even after clicking the Undo, the editing state of the BO remains in 'Adding' until the bindings have all been taken care of.  So, here is my simple fix:


private void SketchPictureEdit_EditValueChanged(object sender, EventArgs e)
{
   
if (partsBO1.Count > 0)   <--addition
    {
       
if (partsBO1.EditingState != MicroFour.StrataFrame.Business.BusinessEditingState.Idle)
        {
           
if (SketchPictureEdit.EditValue == (byte[])null)
            {
               
this.partsBO1.sketch = new byte[] { };
                SketchPictureEdit.EditValue =
string.Empty;
            }
        }
    }
}

Have a great day!!
Bill

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Bill Cunnien - 17 Years Ago
Bill Cunnien - 17 Years Ago
StrataFrame Team - 17 Years Ago
StrataFrame Team - 17 Years Ago
                     Stack Trace: at...
Bill Cunnien - 17 Years Ago
                         Meant to throw this in, too. Your suspicions are correct. Inner...
Bill Cunnien - 17 Years Ago
                             So more than likley you have a filter or sort being set which is...
Trent L. Taylor - 17 Years Ago
                                 Nope...don't think so. Here is my load function: [codesnippet]...
Bill Cunnien - 17 Years Ago
                                     So yup....it is exactly what I said! You have to take this into...
Trent L. Taylor - 17 Years Ago
                                         Thanks, Trent! You got me thinking on the right track. Much...
Bill Cunnien - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search