Loading a RadGridView with a concrecte row selected??

4 posts, 0 answers
  1. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 08 Jan 2014 Link to this post

    Hi ya,

    How can I load my RadGridView in my XAML view showing one row selected by default?

    Thanks in advance for any hint or input related to!!

    I mean,how to set focus on a particular row in my RadGridView?

    Enric
  2. Hristo
    Admin
    Hristo avatar
    41 posts

    Posted 10 Jan 2014 Link to this post

    Hi Enric,

    If you want your application to focus on the first row after loading you can set the property IsSynchronizedWithCurrentItem to true.

    However, if you want to set the focus to row different than the first one, you should do it by setting the SelectedItem property during Loaded event. For example if you want to set it to the third row, the expression will be:
    private void RadGridView_Loaded(object sender, RoutedEventArgs e)
           {
               this.RadGridView.SelectedItem = this.RadGridView.Items[2];
           }

    You should also set the RadGridView property EnableLostFocusSelectedState to False if you don't want to show the the unfocused state. This is explained in more details here: link.

    Regards,
    Hristo
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 13 Jan 2014 Link to this post

    Hi  Hristo, It did the trick. It does works.

    But my goal is a little bit beyond of your solution. At first I would like to search that row before to select it

    Public valuefrom as integer
     Public Sub New(IdPlate as integer)

    valuefrom = IdPlate


    End Sub


        Private Sub dgvOrdenes_Loaded(sender As Object, e As RoutedEventArgs)
    ??
    how can I retrieve the value provided in "valuefrom" variable without using SQL or LINQ some value in my RadGridView??
            Me.dgvOrdenes.SelectedItem = dgvOrdenes.Items(?????)

    End Sub



    I've tried use this snippet but does not works because Rows method is not available at all:

    Dim lastRow As GridViewRowInfo = RadGridView1.Rows(RadGridView1.Rows.Count - 1)
    lastRow.IsSelected = True
    For Each rowInfo As GridViewRowInfo In RadGridView1.Rows
        If rowInfo.IsSelected Then
            rowInfo.EnsureVisible()
        End If
    Next




    Thanks in advance
  5. Hristo
    Admin
    Hristo avatar
    41 posts

    Posted 16 Jan 2014 Link to this post

    Hello Enric,

    Can you provide me with more information? Do you want to search for a row based on some condition, or you want to get all items satisfying the search condition?

    Also please note that RadGridView doesn't have property Rows because the row is a visual element. You should use the property Items when you want to get the item located on a particular row. When RadGridView has enabled virtualization, the only existing items are the items located in the viewport.

    Regards,
    Hristo
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top