微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WPF VB DataGridCombox DataGridRow

如何解决WPF VB DataGridCombox DataGridRow

我已经研究了好几天,找不到解决方案,请帮忙。

我有一个 WPF 应用程序我有一个 DataGridComboBox 它里面有东西(参数列表)。我还可以将手写输入的文本添加到组合框中,例如“测试”,如下图所示。

enter image description here

当我添加“测试”并单击离开或添加新行时,我应该在组合框下拉列表中看到“测试”。相反,我看到“xFRACASDataController.xFRACASFieldMapper+FieldMappingRow”,其中到底是“测试”

enter image description here

这里是 vb。

 Private Sub xDcMappingDataGrid_CellEditEnding(sender As Object,e As DataGridCellEditEndingEventArgs) Handles xDcMappingDataGrid.CellEditEnding
    'get the list from the data grid on mapping tab

    Dim listofRows As New ObservableCollection(Of FieldMappingRow)
    listofRows = dataMapviewmodel.DgRecords
    'For Each r In xDcMappingDataGrid.Items
    '    'stringList.Add(r)
    '    listofRows.Add(r)
    'Next

    dataMapviewmodel.AddtoArgumentDropDownList(sender.Items.CurrentItem.ToString)
    'dataMapviewmodel.AddtoArgumentDropDownList(sender.ArgumentDropDownList(1))
    'dataMapviewmodel.AddtoArgumentDropDownList(sender.Items.ToString)
    'dataMapviewmodel.AddtoArgumentDropDownList(sender.dataGridRow.Item.ToString)
    'dataMapviewmodel.AddtoArgumentDropDownList("TESTING1")
    'dataMapviewmodel.AddtoArgumentDropDownList("TESTING2")
    'dataMapviewmodel.AddtoArgumentDropDownList("TESTING3")
End Sub

这里是 F# 代码

member x.AddtoArgumentDropDownList(argumentText:string) =
          argumentDropDownList.Add(argumentText)
    //Add new Argument in Text to argumentDropDownList
    //Check to see if Text is already in the argumentDropDownList
    //If its there throw it way
    //if Not add it to the argumentDropDownList

    member x.ArgumentDropDownList
        with get() = argumentDropDownList
        and set(t: List<string>) =
            argumentDropDownList.Clear()
            for aField in t do
                argumentDropDownList.Add(aField)
            x.TriggerPropertyChanged("ArgumentDropDownList")

    member x.Arg1
        //with get() = argumentDropDownList
        with set(t: string) =
            //argumentDropDownList.Clear()
            //for aField in t do
            argumentDropDownList.Add(t)
            x.TriggerPropertyChanged("ArgumentDropDownList")

如果我将 Jam "TESTING1" 放在组合框下拉菜单中。我已将手表添加到 Items.CurrentItem。如下所示。 “测试”在 Arg1 中

enter image description here

但不在物理列表中。 任何帮助都非常有帮助。

解决方法

请注意,您的问题不太可能得到很好的答案,因为它非常具体,我们无法运行您的代码。

然而,xFRACASDataController.xFRACASFieldMapper+FieldMappingRow 是一种字符串,当你在一个没有实现任何巧妙的文本格式的对象上运行 ToString 时会得到它——它似乎是一个类的名称,在本例中为 FieldMappingRow(它是 xFRACASFieldMapper 中的嵌套类)。

在您发布的代码中,您在线上调用了 VB 代码中的 ToString

dataMapViewModel.AddtoArgumentDropDownList(sender.Items.CurrentItem.ToString)

sender.Items.CurrentItem 的类型是什么?这可能是 FieldMappingRow 的一个实例吗?如果是这样,那么我认为您需要通过调用 ToString 以外的其他方式从对象中提取文本。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。