Set RadGridView Current/Selected Item

3 posts, 0 answers
  1. Richard
    Richard avatar
    5 posts
    Member since:
    Dec 2013

    Posted 23 Dec 2014 Link to this post

    Hi guys,
    I have a dialog that adds an item to the RadGridView in code behind. I immediately refresh the gvproperties items and search for the newly added item, but it is not present. I want to set the current and selected item to the new item, but indexof() fails. It returns null. Can you see what I might be doing wrong?

     var addWell = new frmAddWellAssignment(_dataContext.SelectedUser.UserID.Trim(), false);

     var assignmentAdded = addWell.ShowDialog();

       if (assignmentAdded == true) {
                    _dataContext.LoadAssignments();
                }

    // RMH: Select the newly added item in the RadGridView

    gvProperties.Items.Refresh();

    var item = gvProperties.Items[gvProperties.Items.IndexOf(addWell.PropertyID)];

    gvProperties.SelectedItem = item;
  2. Richard
    Richard avatar
    5 posts
    Member since:
    Dec 2013

    Posted 23 Dec 2014 in reply to Richard Link to this post

    The support links appear to be broken.
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Dec 2014 Link to this post

    Hi,

    Would you please try setting the SelectedItem in a Dispatcher?
    Dispatcher.BeginInvoke(new Action(() =>
    {
        gvProperties.SelectedItem = item;
    }));

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top