This is a migrated thread and some comments may be shown as answers.

Set RadGridView Current/Selected Item

2 Answers 167 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 23 Dec 2014, 06:54 PM
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 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 23 Dec 2014, 09:16 PM
The support links appear to be broken.
0
Dimitrina
Telerik team
answered on 24 Dec 2014, 12:27 PM
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.

 
Tags
GridView
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or