View previous topic :: View next topic |
Author |
Message |
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Wed Sep 28, 2005 6:26 pm Post subject: Wrong value displayed after cell editing |
|
|
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
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Sep 29, 2005 12:46 am Post subject: |
|
|
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 |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Thu Sep 29, 2005 12:22 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Sep 29, 2005 10:11 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Oct 06, 2005 12:29 am Post subject: |
|
|
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 |
|
|
MHB
Joined: 04 Apr 2005 Posts: 69
|
Posted: Thu Oct 06, 2005 12:50 am Post subject: |
|
|
Well, that explains everything! I wasn't aware of BeginInvoke... Seems quite nice to have
And of course it also works on my real project. Thanks! |
|
Back to top |
|
|
|