I have a situation where the grid will not allow me to set the activerow. Every attempt to set the active row results in a messagebox: Unable to update the row: Object reference not set to an instance of an object.
I am certain that I have set something incorrectly, but troubleshooting this is very difficult. I cannot determine why the grid will not accept the active row. The data is accurate in the grid.
The code below is only for test. It ensures main thread activity. The message appears twice, once when the activerow is being set and again during the call to base.OnMouseDown
_element =
this.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y));
currentRow.Selected =
true;
Hi,
It's impossible to tell from just a code snippet. But if your application is using multiple threads, then that would be my first guess at what's causing the problem.
The grid and the DotNet BindingManager are not thread-safe. So it is extremely difficult, if not impossible, to use multiple threads and safely interact with bound controls.
I did actually see that in another post. We are not using background threads. This occurs in the onmousedownevent handler, which I added invoke code to ensure marshalling to the main thread.