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

Loading a RadGridView with a concrecte row selected??

3 Answers 194 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Enric
Top achievements
Rank 1
Enric asked on 08 Jan 2014, 11:35 PM
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

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 10 Jan 2014, 03:32 PM
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 >>
0
Enric
Top achievements
Rank 1
answered on 13 Jan 2014, 10:28 PM
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
0
Hristo
Telerik team
answered on 16 Jan 2014, 04:13 PM
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 >>
Tags
General Discussions
Asked by
Enric
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Enric
Top achievements
Rank 1
Share this question
or