RadGridView cell collection

3 posts, 1 answers
  1. Customer Care Systems
    Customer Care Systems avatar
    2 posts
    Member since:
    May 2013

    Posted 08 Sep Link to this post

    When I select a row in a RadGridView (as shown below)

        private void gridviewServiceTraceWatchList_SelectionChanged(object sender, SelectionChangeEventArgs e)

                txtBillTo.Text = e.AddedItems[0].ToString();


    I get: “ServiceTrace.WPFApplication.CIPService.ServiceTraceWatchListData”

    I’ve tried everything I know and looked and nothing works. Can anyone tell me what I’m missing? It has to be simple and I'm overthinking it. I just want to get a single field item from a row of data.


    Thanks in advance.



  2. Answer
    Dilyan Traykov
    Dilyan Traykov avatar
    368 posts

    Posted 09 Sep Link to this post


    The AddedItems collection of the SelectionChangeEventArgs returns a collection of objects (single object if SelectionMode is Single) of the type of the bound collection. In this case, I assume your ItemsSource consists of objects of type ServiceTraceWatchListData and thus calling the ToString() method, produces the described result.

    If you have set RadGridView's SelectionUnit to Cell, you can get the value of the field for the last selected cell by handling the SelectedCellsChanged event like so:

    private void radGridView_SelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
        var cell = e.AddedCells[0];
        var field = cell.Item.GetType().GetProperty(cell.Column.UniqueName).GetValue(cell.Item, null);

    Please let me know whether such an approach would work for you.

    Dilyan Traykov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Customer Care Systems
    Customer Care Systems avatar
    2 posts
    Member since:
    May 2013

    Posted 14 Sep in reply to Dilyan Traykov Link to this post

    Awesome. I was overthinking it    o_o



Back to Top