How to set the color of the selected row in a RadGridView

5 posts, 0 answers
  1. Unisense
    Unisense avatar
    34 posts
    Member since:
    Sep 2012

    Posted 17 Oct 2014 Link to this post

    Hi Telerik,

    I have this RadGridView:

    <telerik:RadGridView IsFilteringAllowed="False" BorderBrush="#9AB400" Name="gridView" Grid.Column="0" ItemsSource="{Binding ChamberMeasurements}" AutoGenerateColumns="True" Margin="120,10,12,0" VerticalAlignment="Top" ShowGroupPanel="False">
    </telerik:RadGridView>

    When i click a row in the table created by the RadGridView then the selected row is not highlighted and i don't understand why. Should i set the color of the selected row somehow?

    The ChamberMeasurements property is of type DataTable.

    Can you tell me if i am doing something wrong or missing something?

    Best regards,
    Jeppe
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 22 Oct 2014 Link to this post

    Hello Jeppe,

    It's strange that the selected row is not highlighted. In your application do you use NoXAML binaries with Implicit.Themes and if you do did you modify the theme in any way? 

    I attached a sample project that is bound to a DataTable, however the selected row is highlighted as expected. 

    Could you please examine your project and the attached one for any differences regarding the selection and provide us with additional information about your case? 

    Regards,
    Boris Penev
    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Unisense
    Unisense avatar
    34 posts
    Member since:
    Sep 2012

    Posted 23 Oct 2014 in reply to Boris Link to this post

    Hi Boris,

    I have spent a lot of time examining the differences and found that the table was at some point refreshed with data and therefore the selected value was removed.

    So a new question:
    How do i programmatically select a row in a RadGridView afterwards?

    I have tried something like this to save the selected item:
    var item = gridView.SelectedItem as DataRow;
    _selectedRow = item;

    and later, when the table has been refreshed to set this item again as the SelectedItem:
    gridView.SelectedItem = _selectedRow;

    But this does not work.

    Best regards,
    Jeppe
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Oct 2014 Link to this post

    Hello Jeppe,

    Would you please check if the instance of _selectedRow exists in gridView.Items' collection?

    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.

     
  6. Unisense
    Unisense avatar
    34 posts
    Member since:
    Sep 2012

    Posted 24 Oct 2014 in reply to Dimitrina Link to this post

    Hi Dimitrina,

    I have managed to afterwards highlight the selected row, it work like this:

    foreach (var item in gridView.Items)
    {
        var datarow = item as DataRow;
        if (datarow != null && (datarow["Chamber"].ToString() == viewModel.SelectedChamberNr.ToString()))
        {
            gridView.SelectedItem = item;
        }
    }


    Where the column Chamber is a unique identifier for a row.

    Best regards,
    Jeppe
Back to Top
UI for WPF is Visual Studio 2017 Ready