【问题标题】:Get selected cell in RadGridView Telerik在 RadGridView Telerik 中获取选定的单元格
【发布时间】:2017-05-02 09:08:40
【问题描述】:

需要通过单击按钮绑定到单元格的按钮来编辑单元格。我正在尝试获取,但仍然返回第一行。

XAML:

<telerik:GridViewDataColumn Header="ABC"   DataMemberBinding="{Binding ABC, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
        <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
              <TextBlock Visibility="{Binding ABC}">                                             
              <Hyperlink NavigateUri="{Binding ABC}" RequestNavigate="Hyperlink_RequestNavigate">
              <TextBlock Text="Link" />                                                                 
              </Hyperlink>                                                                   
             <telerik:RadRibbonButton Content="Edit" Grid.Column="1" VerticalAlignment="Center" Size="Small" Width="25" 
SmallImage="..\Images\Edit_16.png" LargeImage="..\Images\Edit_32.png"  Click="RadButtons_Click"></telerik:RadRibbonButton>
              </TextBlock>                                                          
         </DataTemplate>                                                    
         </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

XAML.cs

private void RadButtons_Click(object sender, RoutedEventArgs e)
    {            
            this.grdgetval.CurrentCellInfo // This always returns the first row
            this.grdgetval.BeginEdit();        
    }

我哪里错了?以及需要添加什么?

【问题讨论】:

    标签: c# wpf xaml telerik radgridview


    【解决方案1】:

    我没有得到您想要的,但您可以尝试以下方法之一:

    this.radGridView1.CurrentCell.ColumnInfo.Name
    this.radGridView1.SelectedRows[0].Cells["Picture Name"].Value
    this.radGridView1.CurrentRow.Cells[0].Value
    

    希望对你有所帮助。

    【讨论】:

      【解决方案2】:

      如果您想以编程方式在编辑模式下发送当前单元格,您必须使用以下代码 -

      this.grdgetval.CurrentCell.BeginEdit()
      

      如果您想在单击按钮时编辑单元格(我假设是您的情况),您必须首先将所需的单元格设置为 CurrentCell,如下所示 -

      this.grdgetval.CurrentCellInfo = cellToEdit; // cellToEdit-the cell to be edited    
      this.grdgetval.BeginEdit();
      

      希望这会有所帮助!

      【讨论】:

      • CurrentCell 总是返回第一行。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多