KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

TreeView and LabelEdit

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Ashmite
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Apr 2004
Posts: 13

PostPosted: Mon Oct 31, 2005 7:05 pm    Post subject: TreeView and LabelEdit Reply with quote

It doesn't appear possible to apply the LabelEdit property to an individual node. Is this correct? I'm playing with something that would be nice to allow users to add/rename their own nodes, but not the base ones that the application provides.

Does anyone have any thoughts on how to jury-rig this?

Thx

--Joel
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Nov 01, 2005 12:14 am    Post subject: Reply with quote

your hunch is right. cant disable labeledit on a per-node basis (in kf2).
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Tue Nov 01, 2005 1:58 am    Post subject: Reply with quote

True, you can not set the .labeledit property for individual nodes but if you know the names of the nodes that you don't want it disabled/enabled for then you can disable/enable the .labeledit property for that node, sorta.

in this example i disable the .labeledit property for 'Node0', 'Node1', 'Node2', 'Node3', 'Node4', 'Node5' and enable it for all others :
Code:
Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.Size = 640,480
$Form.Text = "Blank Form"
$Form.Center
$Form.Font = $System.Font("Verdana",10)

$StatusBar = $Form.StatusBar()
$StatusBar.Dock = "Bottom"

$Treeview = $Form.Controls.TreeView()
$Treeview.Dock = "Left"
$Treeview.ImageList = $System.BuiltinImageList()
$Treeview.ImageIndex = 45
$TreeView.LabelEdit = false
$Treeview.SelectedImageIndex = 46
$Treeview.OnMouseDown = "TreeViewMouseDown()"

$Treeview.ContextMenu1 = $System.ContextMenu()

$Treeview.ContextMenu1.ExpandMenu = $Treeview.ContextMenu1.MenuItems.Add("Expand")
$Treeview.ContextMenu1.ExpandMenu.Visible = 1
$Treeview.ContextMenu1.ExpandMenu.Enabled = true
$Treeview.ContextMenu1.ExpandMenu.Onclick = "OnExpandClick()"

$Treeview.ContextMenu1.CollapseMenu = $Treeview.ContextMenu1.MenuItems.Add("Collapse")
$Treeview.ContextMenu1.CollapseMenu.Visible = 1
$Treeview.ContextMenu1.CollapseMenu.Enabled = false
$Treeview.ContextMenu1.CollapseMenu.OnClick = "OnCollapseClick()"

$ROOTCOUNT = 5
$CHILDCOUNT = 5

For $i = 0 to $ROOTCOUNT
 $RootNode = $TreeView.Nodes.Add("Node$i")
 For $j = 0 to $CHILDCOUNT
  $ChildNode = $RootNode.Nodes.Add("Child$j")
 Next
Next

$Listview = $Form.ListView()
$Listview.Dock = "Fill"
$Listview.SmallImageList = $System.BuiltinImageList

$= $Listview.Columns.Add("Child",100,$System.HorizontalAlignment.Left )

$Form.Show
While $Form.Visible
 $= Execute($Form.DoEvents())
Loop

Exit 0

Function TreeViewMouseDown()
   
   Dim $Node
   
   $Node = $TreeView.GetNodeAt($TreeView.MouseX, $TreeView.MouseY)
   
   If Not $Node
      Return
   EndIf
   
   If Not($Node.Text = "Node0" Or $Node.Text = "Node1" Or $Node.Text = "Node2" Or $Node.Text = "Node3" Or $Node.Text = "Node4" Or $Node.Text = "Node5")
      $TreeView.LabelEdit = true
   Else
      $TreeView.LabelEdit = false
   EndIf
   
   If Not ($TreeView.MouseButton & 2) ;; Not right-click ?
      Return
   EndIf
   
   $TreeView.SelectedNode = $Node
   
   If $Node.Expanded = 0
      $Treeview.ContextMenu1.ExpandMenu.Enabled = true
      $Treeview.ContextMenu1.CollapseMenu.Enabled = false
   Else
      $Treeview.ContextMenu1.ExpandMenu.Enabled = false
      $Treeview.ContextMenu1.CollapseMenu.Enabled = true
   EndIf
   
   $= $TreeView.ContextMenu1.Show($TreeView, $TreeView.MouseX, $TreeView.MouseY)
   
EndFunction

Function OnExpandClick()
   
   If $TreeView.SelectedNode
      $TreeView.SelectedNode.Expand()
   EndIf
   
EndFunction

Function OnCollapseClick()
   
   If $TreeView.SelectedNode
      $TreeView.SelectedNode.Collapse()
   EndIf
   
EndFunction


this is the key piece of code (found in the TreeViewMouseDown() Function):
Code:
   If Not($Node.Text = "Node0" Or $Node.Text = "Node1" Or $Node.Text = "Node2" Or $Node.Text = "Node3" Or $Node.Text = "Node4" Or $Node.Text = "Node5")
      $TreeView.LabelEdit = true
   Else
      $TreeView.LabelEdit = false
   EndIf


_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)


Last edited by benny69 on Tue Nov 01, 2005 2:10 am; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Nov 01, 2005 2:01 am    Post subject: Reply with quote

clever ! very, very clever !
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Tue Nov 01, 2005 2:09 am    Post subject: Reply with quote

thank you shawn,
i can not take full credit for this, shawn showed me something very similar a long time back, i just expanded on it.

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Nov 02, 2005 1:54 pm    Post subject: Reply with quote

ja, clever mind works just fine when it needs to!

nice.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Ashmite
KiXforms Dabbler
KiXforms Dabbler


Joined: 27 Apr 2004
Posts: 13

PostPosted: Fri Nov 04, 2005 6:27 pm    Post subject: Reply with quote

That's exactly what I was trying to figure out, but I couldn't find the right method/event to trigger the enable/disable.

And, I do indeed know exactly which Nodes I want to remain read-only.

Thanks for the assist!

--Joel
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group