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

Setting a value of the grid.

1 Answer 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scuttle
Top achievements
Rank 1
Scuttle asked on 26 May 2017, 12:00 PM

Hi,

I have this code and I need to set the value of one column based on the SelectedItem (SelectedItemMyRecord) binded in the grid. The value will be set after clicking a button. Can someone help me on this?

 

<telerik:RadGridView Grid.Row="1"                                   
                                     Height="300"                                 
                                     ItemsSource="{Binding MyRecords, Mode=TwoWay}"                                       
                                     SelectionMode="Single"                                    
                                     Name="radGridViewMyList"
                                     telerikGridViewHeaderMenu:GridViewHeaderMenu.IsEnabled="True"
                                     FontSize="{Binding GridFontSize}"
                                     IsReadOnly="False"
                                     SelectedItem="{Binding SelectedItemMyRecord, Mode=TwoWay}"                                     
                                     RowIndicatorVisibility ="Visible"                                                                     
                                     RowDetailsVisibilityMode="VisibleWhenSelected"

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 30 May 2017, 11:56 AM
Hello Scuttle,

The suggested approach would be to work with the bound data items. Thus, you can do something similar to:

private void Button1_Click(object sender, RoutedEventArgs e)
{
    var selectedItem = radGridView.SelectedItem as Club;
    var newName = selectedItem.Name;
    foreach (var item in radGridView.Items)
    {
        var club = item as Club;
        club.Name = newName;
    }
}

Do let me know whether this would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Scuttle
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or