由此贴引申出此想法
http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=15627&page=1&star=1
代码如下,本来是写 Drawcell事件里,但我想把他写成全局代码,再在Drawcell里调用 这个,
另外类似CreateTree,但不用分隔符就能就能实现多级目录树,和下面的这个单列多级字典相似的,代码该怎么写呢。最好是我能自定义个窗体控件的事件。
If e.Row.IsNull("第三列") = False AndAlso e.Col.Name = "第三列" Then
Dim sor As Long = 2 '次级科目编号位数
Dim ii As Long = 4 '一级科目编号位数
Dim s As String = e.Row("第三列") '输入值
If s.Length<ii OrElse (s.Length-ii) Mod sor<>0 Then
e.Row("第三列")=Nothing
Else
Dim dr1,dr2 As DataRow
Dim ss As String =Nothing
'----
For i As Long =ii To s.Length Step sor
dr1 = DataTables("表A").Find("第一列 = '" & s.substring(0,i) & "'")
Dim va As String =""
If dr1 Is Nothing Then
messagebox.Show("会计科目编号未使用","错误")
e.Row("第三列")=Nothing
Exit For
Else
If I<s.Length Then va="\"
ss= ss & dr1("第二列") & va
End If
Next
'---
e.Text = ss
End If