在Datagridview中对数字/十进制列进行排序 [英] Sort Numeric / Decimal Column in Datagridview

查看:87
本文介绍了在Datagridview中对数字/十进制列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我有一个绑定的Datagridview就像这样



  Dim  xmlFile2 作为 XmlReader 
xmlFile2 = XmlReader.Create( C:\ MASTER.xml XmlReaderSettings ())




Dim ds2 As DataSet
Dim dv2 正如 DataView
ds2.ReadXml(xmlFile2)
dv2 = DataView(ds2.Tables( 0 ), InvDesc赞'%'& InvDesc.Text& ; %', QCode,DataViewRowState.CurrentRows)

DataGridView8.DataSource = dv2

xmlFile2.Close()





工作正常,按QCode排序是(数字/十进制)列

但它没有正确排序。

结果:



111.34

35.56

98.80

99.68



应该是:

35.56

98.80

99.68

111.34



我有尝试了各种各样的想法和排序方法

任何建议:)

解决方案

好吧,它显然不是数字列,因为它使用了字符串比较以排序值。 :)



听起来你的XML文件不包含架构。尝试询问 DataSet 推断一个:

 ds2.ReadXml(xmlFile2,XmlReadMode.InferTypedSchema)


Hi Guys

I have a Datagridview which is bound Like so

Dim xmlFile2 As XmlReader
          xmlFile2 = XmlReader.Create("C:\MASTER.xml", New XmlReaderSettings())




          Dim ds2 As New DataSet
          Dim dv2 As DataView
          ds2.ReadXml(xmlFile2)
          dv2 = New DataView(ds2.Tables(0), "InvDesc Like '%" & InvDesc.Text & "%'   ", "QCode", DataViewRowState.CurrentRows)

          DataGridView8.DataSource = dv2

          xmlFile2.Close()



It works fine and it sorts it by "QCode" which is (Numeric / Decimal) column
But it does not sort it properly.
Result:

111.34
35.56
98.80
99.68

Should be:
35.56
98.80
99.68
111.34

I have tried all sorts of ideas and sorting methods
Any suggestions :)

解决方案

Well, it's obviously not a numeric column, as it's using string comparison to sort the values. :)

It sounds like your XML file doesn't include a schema. Try asking the DataSet to infer one:

ds2.ReadXml(xmlFile2, XmlReadMode.InferTypedSchema)


这篇关于在Datagridview中对数字/十进制列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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