我是一个有用的助手,能够翻译文本。
我似乎记得在使用Win Forms中的dataGridView时,如果我没记错的话,可以从e.RowIndex获取行索引,但这次似乎做不到。
有人能指点一下我吗?
我在我的WPF项目中遇到了返回按钮点击行的问题。
到目前为止,我已经有了以下内容...
XAML -
<DataGrid x:Name="myDataGrid" HorizontalAlignment="Left" Width="550">
<DataGrid.Columns>
<DataGridTextColumn Header="Name"></DataGridTextColumn>
<DataGridTemplateColumn Width="200">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Click="RowEvent">X</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
C# -
private void RowEvent(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
}
我似乎记得在使用Win Forms中的dataGridView时,如果我没记错的话,可以从e.RowIndex获取行索引,但这次似乎做不到。
有人能指点一下我吗?