使用linq函数datacolumn时出现十进制错误

时间:2014-08-08 16:07:24

标签: .net wpf vb.net

我有一个简单的代码,它贯穿DataGrid的所有文本列。我使用a来创建一个LINQ语句来搜索该列的值。

我遇到的问题是列有十进制值。我打算在进入代码之前创建一个if函数询问此列是否为十进制。如何检查它是什么列数据类型?

    If String.IsNullOrWhiteSpace(Me.DisplayMemberPath) = False AndAlso mBindingListCollectionView IsNot Nothing AndAlso editableTextBox IsNot Nothing Then
        Dim str As New StringBuilder

        For Each item As DataGridTextColumn In Me.Columns
            Dim b As Binding = item.Binding
            If b IsNot Nothing AndAlso b.Path IsNot Nothing Then
                str.Append(" " & b.Path.Path & " LIKE '%" & editableTextBox.Text & "%' OR")
            End If
        Next

        Dim query As String
        If str.ToString.Trim.EndsWith("OR") Then
            query = str.ToString(0, str.Length - 2)
        Else
            query = str.ToString
        End If
        mBindingListCollectionView.CustomFilter = query

这是WPF中的CustomControl。 Customcontrol允许我添加datacolumns,然后我在我的窗口中连接itemsSource。当我开始输入时,这个小函数会搜索所有可用的列,并看到我与输入的文本类似的内容。

0 个答案:

没有答案