如何做到以下情形: 我有一些数据表,其中包含例如一些行:
How to do following scenario: I have some DataTable which contains for example some rows:
1.rowa 2.rowab 3.row 4.rowaba ... ñ。 rowabba
1.rowa 2.rowab 3.row 4.rowaba ... n. rowabba
如何通过lenght排序行,叫不上名字。我婉通过字段长度排序表。
How to sort rows by lenght, not by name. I wan to to sort Table by length of fields.
您可以添加一个额外的列到你的数据表
,提供包含通话的前pression到 len个()
的功能,从而导致该列的值进行自动计算:
You could add an extra column to your DataTable
, supplying an expression containing a call to the len()
function, causing the column's values to be automatically computed:
table.Columns.Add("LengthOfName", typeof(int), "len(Name)");
那么你可以简单排序在你之前,结合新列的数据表
来您打算使用任何类型的UI控件的网格:
Then you can simply sort on your new column before binding the DataTable
to a grid to whatever kind of UI control you plan to use:
table.DefaultView.Sort = "LengthOfName";