Home Forums WPF controls Xceed DataGrid for WPF DataGridControl values don’t sync after being edited

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25272 |

    When I try to retrieve values from Items or ItemsSource of a DataGridControl it only
    shows the original values. If I change values on the visible grid those values do not get populated into the itemsSource or Items variable and I have no way to retrieve them. More specifically I would like to capture the event of when a cell is edited and have this event tell me the row, column and new text value that was entered when the cell was updated. If not I at least need to go through all cells and be able to find the updated values. Right now I can only see the original values even when I turn the watch on DataGridControl and look through all of its properties and methods I only see the old values.

    I set up the datagridcontrol like so:
    Set up d as a DataGridControl with the # of columns I will need based on the query.
    object[][] items = set up an array of items
    d.ItemsSource = items;

    Then after the user edits values I try to retrieve the edited values and I get back the values I originally submitted to the data grid control. I would like to get back the values that are displayed on screen.

    This is the function I was trying to use to get back the edited values:
    public string getTextByLocation(int row, int column)
    {
    object[][] items = (object[][])d.ItemsSource;
    object[] data = (object[])items[row];
    return data[column].ToString();
    }

    Imported from legacy forums. Posted by Mark (had 2254 views)

    User (Old forums)
    Member
    Post count: 23064

    The solution was I just needed to add the end edit line:

    public string getTextByLocation(int row, int column)
    {
    d.EndEdit();
    object[][] items = (object[][])d.ItemsSource;
    object[] data = (object[])items[row];
    return data[column].ToString();
    }

    Imported from legacy forums. Posted by Mark (had 207 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    Can i ask how you were capturing the edit event in the first place? I really can’t figure it out – I am porting some Windows Forms code to WPF and can’t for the life of me see what the analogous event to DataGridView::CellEndEdit is…

    Thanks in advance!
    Scott

    Imported from legacy forums. Posted by Scott (had 3410 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.