【问题标题】:How to display selected items in a DataGrid to a TextBox using VB.NEW and WPF如何使用 VB.NEW 和 WPF 将 DataGrid 中的选定项目显示到 TextBox
【发布时间】:2013-03-25 09:26:09
【问题描述】:

我被一个看似相当简单的问题所困扰,我正在使用 WPFVB.NET 2010。 我用 MySQL 数据库中的数据填充了我的DataGrid,我希望当我单击DataGrid 上的特定行时,行内容显示在TextBox 中,我尝试使用 VB.NET WinForms 代码,但它似乎不起作用。

Dim i as integer
i = dgvGrid.CurrentRow.Index
textbox1.text = dgvGrid.Item(0, i).Value

这是我将在 WinForms 中使用的示例代码 请帮忙!

【问题讨论】:

  • 您是否已经尝试在控件之间使用 DataBinding ?
  • 不,我还没有,我最近从 winforms 转移,所以还在学习 WPF。
  • I recently shifted from winforms - 欢迎来到光明的一面。请忘记你从 winforms 中学到的一切,并确保你没有在 WPF 中应用它。
  • 好的,所以,你应该读一下:codeproject.com/Articles/29054/WPF-Data-Binding-Part-1 在那之后,我想你可以自己解决你的问题:-)

标签: wpf vb.net datagrid


【解决方案1】:

我终于找到了如何做到这一点,

Dim row as datarowView = Ctype(Datagrid1.selectedItem(0),Datarowview)
textbox1.text = string.format(Trim(row("ColumnName").ToString

ColumnName 只是数据网格中列标题的名称

【讨论】:

    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 2015-10-31
    • 2022-11-24
    • 2020-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多