任何人都可以帮助使用WPF DataGridView吗? [英] Can anyone help with WPF DataGridView?

查看:95
本文介绍了任何人都可以帮助使用WPF DataGridView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我是WPF的新手,我对DataGridView有问题.
我有一个同时打开两个UserControl的MainWindow.
在第一个UserControl中,我有一个DataGridView.我想双击它并查看数据
在第二个UserControl TextBoxes中.

在此先感谢

Hi guys

I''m new to WPF and I have a problem with DataGridView.
I have a MainWindow with two UserControls open at the same time.
In the first UserControl I have a DataGridView. I want to double click in it and see the data
in the second UserControl TextBoxes.

Thanks in advance

推荐答案

好,单击此事件时获得该行:

Ok, Get that row when clicked with this event :

private void MyDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           DataGridRow row =      (DataGridRow)MyDataGrid.ItemContainerGenerator.ContainerFromItem(MyDataGrid.SelectedItem);
         int  TaSelectedItem = MyDataGrid.Items.IndexOf(MyDataGrid.SelectedItem);
       }



然后获取它的项目并将其放入文本框.



And then Get it items and put them into textboxes.


这篇关于任何人都可以帮助使用WPF DataGridView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆