#region 设置小数点private void gridView4_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.base.CustomColumnDisplayTextEventArgs e){ if (e.DisplayText != "") { //利用正则表达式判断当前列值不包含中文 //System.Text.Regularexpressions.Match result=System.Text.Regularexpressions.Regex.Match(e.DisplayText, "^[^0-9^.]+"); //^:代表从字符串开头进行匹配 //.*[^0]:代表匹配当前字符串中不为0的字符(.*为贪婪匹配模式,会尽可能多的在字符串中匹配不为0的字符 //如果字符如0.0234000;匹配结果为0.0234) System.Text.Regularexpressions.Match result1 = System.Text.Regularexpressions.Regex.Match(e.DisplayText, "^.*[^0]"); if (result1.Value.EndsWith(".")) e.DisplayText = result1.Value + "0"; else e.DisplayText = result1.Value; }}#endregion