Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1365
DeepCopy before refreshing
posted

hi

i have a winform with wingrid 13.2 and having trouble after refreshing the grid. On the grid_mouseup i'm capturing the currently selected cell  in the grid to a global variable, but the grid is refreshed after i grab cell. So it looks like my reference to the original cell object is lost. can i deepcopy the object so i don't lose it after refresh?

some code:

 void ultraGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Infragistics.Win.UIElement element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(e.Location);

            _lastUIGridElement = element; // should i deepcopy this obj?

}

really appreciate the help

Thanks

Al

Parents
  • 48586
    Verified Answer
    posted

    Hello Allen,

     

    You shouldn’t keep reference to UIElements, because they are maintained by the PLF and might be reused, which meant that you might expect it to refer a specific cell on the screen, but it actually is for another cell. So you should modify your code like:

    UltraGridCell _lastUIGridElement;  

     void ultraGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
            {
                Infragistics.Win.UIElement element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(e.Location);

                _lastUIGridElement = element.GetContext(typeof(UltraGridCell)) as UltraGridCell;

    }

     

    So if you need to get the UI element in later stage of this cell you could use following line:

     

    _lastUIGridElement. GetUIElement()

     

    Please let me know if you have any further questions.

     

     

Reply Children
No Data