views:

382

answers:

1

My VB.Net Winforms app is a tool to allow hierarchical data to be edited in a tree, then stored in a database. I am using a treeview control.

Content is drag-dropped from other documents onto the treenodes, or the nodes can be edited directly.

if I edit the database field directly, and enter a bit of content (a thousand characters long or more!), the treeview will happily display it.. but, when I drag drop, the data is being truncated at 259 characters. If I edit directly, the maximum edit 'window' is also 259 characters.

259 seems like a really strange number to stop at, so I am wondering - where does this size come from, and can I change it programmatically?

+2  A: 

I would recommend taking a different approach. You probably don't want to show your users all 10000 or characters of a document anyway in their TreeNode, so create an custom data storage class with properties like Name and Content to store the document and it's title. Add your content to the Content property and a title or something meaningful to the Name property then add the object to the Tag property of the TreeNode object.

Dim mynode As New TreeNode
Dim SomeBigCustomObject as New MyContentStorageObject(name,content)
mynode.Text = SomeBigCustomObject.Name
mynode.Tag = SomeBigCustomObject
TreeView1.Nodes.Add(mynode)

You can then get the object back when a node is selected (using the AfterSelect event) like this:

dim ContentStorageObject As MyContentStorageObject = CType(e.Node.Tag,   MyContentStorageObject)
dim content as string = ContentStorageObject.Content

If you need to edit the text, I would then either pop up a editor dialog or send the data that is stored in Content to an textbox on your form for editing. Your users will probably appreciate not having to type it all in the treeview node editor.

That's a real quick and dirty explanation, but the essence is "use the .Tag property". Good luck.

Steve Massing
This is what I ended up doing - displaying a shorter bit of text and added a 'tag' entry allowing the content to be loaded as required and popped into a seperate multiline textbox to edit - plus points, it's faster and forced me to redesign the UI.
TheoJones