修改代码
Dim e = Args(0)
Dim ColName As String = Args(1)
If e.Col.Name = ColName Then
Dim i1 As Integer
Dim i2 As Integer
Dim ary() As String = e.text.split("*")
Dim swidth As Double = 0
For i As Integer = 0 To ary.length-1
Dim t As String = ary(i)
Dim ts() As String = {"","",""}
t = t.Replace("^^","|")
If t.Contains("^")
Dim ts2() As String = t.Split("^")
ts(0) = ts2(0)
If ts2.Length = 2 Then ts(1) = ts2(1)
ElseIf t.Contains("|")
Dim ts3() As String = t.Split("|")
ts(0) = ts3(0)
If ts3.Length = 2 Then ts(2) = ts3(1)
End If
If ts(1) > "" AndAlso ts(1).Contains("|") Then
Dim ss() As String = ts(1).Split("|")
ts(1) = ss(0)
ts(2) = ss(1)
End If
StatusBar.Message2 = ts(1)
Dim reg As new System.Text.RegularExpressions.Regex("^[+0-9\d\.*/]+$")
Dim reg1 As new System.Text.RegularExpressions.Regex("^[+0-9\d\-+.*/]+$")
If ts.Length >= 2 AndAlso reg.IsMatch(ts(0)) Then
Dim RectF As RectangleF '绘制区域
Dim fnt1 As Font = e.Table.Grid.Cols(e.Col.Name).Style.Font.Clone() '获取大字体
If e.Height > fnt1.Height Then
RectF = New RectangleF(e.x+swidth,e.y + (e.Height - fnt1.Height)/2,e.Width ,fnt1.Height)
Else
RectF = New RectangleF(e.x+swidth,e.y,e.Width ,e.Height)
End If
Dim FI As New C1.C1Preview.Util.FontInfo(fnt1)
Dim fnt2 As New Font(fnt1.Name,FI.SuperscriptSize) '获取小字体
Dim size As SizeF = e.Graphics.MeasureString(ts(0), fnt1) '计算大字体的位置
Dim sf As new StringFormat
sf.Trimming = 2
e.Graphics.DrawString(ts(0),fnt1,Brushes.Red,RectF ,sf)
Dim s1,s2 As object
If ts(1) > "" AndAlso reg1.IsMatch(ts(1)) Then
e.Graphics.DrawString(ts(1),fnt2,Brushes.Red,new RectangleF(RectF.x + (size.Width - fnt1.size/2 +2),RectF.y ,RectF.Width,RectF.Height) ,sf)
s1 = e.Graphics.MeasureString(ts(1), fnt2)
End If
If ts(2) > "" AndAlso reg1.IsMatch(ts(2)) Then
e.Graphics.DrawString(ts(2),fnt2,Brushes.Red,new RectangleF(RectF.x + (size.Width - fnt1.size/2 +2),RectF.y+RectF.Height/2+1 ,RectF.Width,RectF.Height) ,sf)
s2 = e.Graphics.MeasureString(ts(2), fnt2)
End If
swidth += size.width
If s1 IsNot Nothing AndAlso s2 IsNot Nothing Then
swidth += iif(s1.width>s2.width, s1.width, s2.width)
ElseIf s1 IsNot Nothing Then
swidth += s1.width
Else
swidth += s2.width
End If
If i < ary.length-1 Then
e.Graphics.DrawString("*",fnt1,Brushes.Red, RectF.x+swidth-3, RectF.y,sf)
size = e.Graphics.MeasureString("*", fnt1)
swidth += size.width
End If
e.Text = ""
End If
Next
End If
[此贴子已经被作者于2017/5/11 9:18:58编辑过]