How can I get the whole row in a RadGridView?

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

    Posted 11 Sep 2013 Link to this post

    I want to allocate in ClipBoard object the selected row:
    xaml:

    <telerik:RadGridView x:Name="dgvOrdenes" ShowGroupPanel="False" ShowColumnHeaders="True" ShowColumnFooters="False"
                                ItemsSource="{Binding V_Or2}" HorizontalAlignment="Left"
                                Margin="10,44,-83,0" ShowInsertRow="False" VerticalAlignment="Top" Height="216"
                                Width="810" Grid.RowSpan="4" AutoGenerateColumns="False" Grid.ColumnSpan="3" >
     
               <telerik:RadGridView.Columns>
                   <telerik:GridViewDataColumn DataMemberBinding="{Binding [Or]}" Header="{Resx RadGridViewOr_Or}" />
                   <telerik:GridViewDataColumn DataMemberBinding="{Binding Alta}" Header="{Resx RadGridViewOr_Alta}" />
                   <telerik:GridViewDataColumn DataMemberBinding="{Binding Cierre}" Header="{Resx RadGridViewOr_Cierre}" />
                   <telerik:GridViewDataColumn DataMemberBinding="{Binding Matricula}" Header="{Resx RadGridViewOr_Matricula}" />
                   <telerik:GridViewDataColumn DataMemberBinding="{Binding Modelo}" Header="{Resx RadGridViewOr_Modelo}" />
               </telerik:RadGridView.Columns>
     
               <ContextMenuService.ContextMenu>
                   <ContextMenu>
     
                       <MenuItem Click="MenuItem6_Click" Header="copy row" >
                           <MenuItem.Icon>
                               <Image Source="/Imagenes/bullet-blue-icon.png" Height="10" Width="10"/>
                           </MenuItem.Icon>
                       </MenuItem>
     
     
                   </ContextMenu>
               </ContextMenuService.ContextMenu>
     
     
           </telerik:RadGridView>


    code-behind: (it does fails)
    Private Sub MenuItem6_Click(sender As Object, e As RoutedEventArgs)
     
           Clipboard.SetData(DataFormats.Text, TryCast(Me.dgvordenes.ItemContainerGenerator.ContainerFromItem(Me.dgvordenes.SelectedItem), R)
     
     
     
     
       End Sub
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Sep 2013 Link to this post

    Hello,

    You can get the row corresponding to an item using the following code:

    GridViewRow selectedRow = this.clubsGrid.ItemContainerGenerator.ContainerFromItem(this.clubsGrid.SelectedItem) as GridViewRow;
    Dim selectedRow As GridViewRow = TryCast(Me.clubsGrid.ItemContainerGenerator.ContainerFromItem(Me.clubsGrid.SelectedItem), GridViewRow)

    Please note that only the rows that are currently in view will be returned. This is due to the fact that the RadGridView supports UI Virtualization as explained in this help article. Regards,
    Didie
    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 12 Sep 2013 Link to this post

    thanks a lot
Back to Top