Faceți căutări pe acest blog

duminică, 20 august 2017

Invalid keys in a TreeView Control

Each node of a TreeView has a key. The key is a string and must be unique [2].
Accidentally I discovered some unacceptable values for this key [3].

Generally, are rejected values that resembles a number:
- Integer literals, like '1'
- Integer literals followed by a period, like '1.'
- Integer literals preceded or folowed by a symbol sign, like '+1' or '1-'
- Numbers with commas between its digits, like '1,' ; '1,1,1' ; '1.,' or '.1,'
- Integer literals preceded or folowed by Space, Tabe or CR

Please try following example.



PUBLIC ofrm
ofrm=CREATEOBJECT("MyForm")
ofrm.show()

DEFINE CLASS MyForm as Form
      autocenter = .T.
      ADD OBJECT teeview as olecontrol WITH oleclass = 'COMCtl.treectrl', width = 300,height = 350
      PROCEDURE init
            LOCAL lcRoot,loRoot
            lcRoot='Root'
            loRoot = thisform.TeeView.Nodes.Add(, 1, m.lcRoot,'Root node')
            loRoot.Expanded = .T.
            * Rejected
            thisform.AddNode(m.lcRoot,'1')
            thisform.AddNode(m.lcRoot,'1.')
            thisform.AddNode(m.lcRoot,'1,')
            thisform.AddNode(m.lcRoot,'+1')
            thisform.AddNode(m.lcRoot,'1.,')
            thisform.AddNode(m.lcRoot,'.1,')
            thisform.AddNode(m.lcRoot,'-1')
            thisform.AddNode(m.lcRoot,'1+')
            thisform.AddNode(m.lcRoot,'1-')
            thisform.AddNode(m.lcRoot,' 1')
            thisform.AddNode(m.lcRoot,'1 ')
            thisform.AddNode(m.lcRoot,CHR(13) + '1')
            thisform.AddNode(m.lcRoot,CHR(9) + '1')
            thisform.AddNode(m.lcRoot,'1,1,1,1')
           
            * Accepted
            thisform.AddNode(m.lcRoot,CHR(13))
            thisform.AddNode(m.lcRoot,CHR(9))
            thisform.AddNode(m.lcRoot,'1 1')
            thisform.AddNode(m.lcRoot,'1E')
            thisform.AddNode(m.lcRoot,'1+1')
      ENDPROC
      PROCEDURE AddNode
            LPARAMETERS lcRoot, lcKey
            LOCAL loErr as Exception
            TRY
                  thisform.TeeView.Nodes.Add(m.lcRoot, 4, m.lcKey,m.lcKey)
            CATCH TO loErr
                  ACTIVATE SCREEN
                  ? m.lcKey, loErr.ErrorNo , loErr.Message
            ENDTRY
      ENDPROC
ENDDEFINE


Bibliography
[1] TreeView Control
[2] Key Property
[3] The code the lead me to these conclusions

Related posts
http://praisachion.blogspot.com/2017/09/correlation-between-margin-and-fontsize.html
http://praisachion.blogspot.com/2017/08/invalid-keys-in-treeview-control.html

Niciun comentariu:

Trimiteți un comentariu