Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wrong value displayed after cell editing

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
MHB



Joined: 04 Apr 2005
Posts: 69

PostPosted: Wed Sep 28, 2005 6:26 pm    Post subject: Wrong value displayed after cell editing Reply with quote

In a cell editor, I enter a new value, a. After pressing enter, a is programmatically put in the right place. After this, the new value (b) of the cell may be different from what was entered (a). Therefore, I call UpdateRowData() to make sure the new value b is displayed. Now the editor displays the correct value, b. However, when clicking another cell and the editor is closed, a is displayed in the edited cell! Only after clicking the cell again, followed by clicking somewhere else, is the correct value b shown.

This looks more complicated than it actually was Smile
Bottom line is: It looks like the value entered in a cell editor is cached and shown instead of the actual cell value.

The situation is the same for a simple TextBox and UniversalEditBox, so the problem must be within VirtualTree.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Sep 29, 2005 12:46 am    Post subject: Reply with quote

My guess is that an error is occuring in the Dataset while attempting to save the new value. Ensure SuppressErrorMessages is set to false and then take a look in your debug output window while doing this to see if there are any error messages that might help.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
MHB



Joined: 04 Apr 2005
Posts: 69

PostPosted: Thu Sep 29, 2005 12:22 pm    Post subject: Reply with quote

Well, I'm not using a Dataset, but programmatic data binding (which I tried to hint with "programmatically put in the right place"), and I can see that the new value is successfully saved. And SuppressErrorMessages has always been false, but I don't think I've ever seen output from it.

After calling UpdateRowData(), I can see that the correct new value is loaded in the object displayed by the row, but as I tried to explain, the new value is not displayed before deactivating, activating and again deactivating the editor. Then the correct value is actually displayed, so it's not as if the data entry never made it through...
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Sep 29, 2005 10:11 pm    Post subject: Reply with quote

I'm thinking that a sample project illustrating the problem might help us understand the issue - if you could email one to support@infralution.com we will take a look.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Oct 06, 2005 12:29 am    Post subject: Reply with quote

Thanks for the sample project. The problem is that the code that sets the value in the tree looks something like:

Code:

object newValue = _editor.GetValue(_editorControl);
if (ValueChanged(_cellData.Value, newValue))
{
    if (Tree.SetValueForCell(Row, Column, _cellData.Value, newValue))
    {
        _cellData.Value = newValue;
    }
}


Your code that sets the value - and then calls UpdateRowData to update the CellData.Value to your modified value is called synchronously from withing SetValueForCell. So you can see that the next line of code will set the cellData.Value to the original value from the editor.

The solution to this is to call UpdateRowData asychronously. eg

Code:

public delegate void UpdateRowDataDelegate();

public string Prop1
{
   get { return prop1; }
   set
   {
        if (value != prop1)
        {
            prop1 = "Real value: " + value;
            tree.BeginInvoke(new UpdateRowDataDelegate(tree.UpdateRowData));
        }
    }
}


This means that UpdateRowData won't be called until after the thread setting the value has finished executing. I've tested this on your sample project and it works fine.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
MHB



Joined: 04 Apr 2005
Posts: 69

PostPosted: Thu Oct 06, 2005 12:50 am    Post subject: Reply with quote

Well, that explains everything! I wasn't aware of BeginInvoke... Seems quite nice to have Smile

And of course it also works on my real project. Thanks! Cool
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group