473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB.Net - Treeview Logic Problem

9
Hi all
My Treeview is working fine with the following layout
Expand|Select|Wrap|Line Numbers
  1. 1 Parent
  2.  
  3. 2 Parent
  4.     1 Child
  5.     2 Child
  6.  
  7. 3 Parent
  8. ..............etc
I have used the MSDN code sample

If tx.Text.Length <> tx.Text.Length Then
Return tx.Text.Length - ty.Text.Length
End If
Return String.Compare(ty.Text, tx.Text)

Which sorts by length - it works but not a whole lot of use.

Could someone point me please to the answers to my 2 problems.

1 How do I sort by node number 1 2 3 - 10 11 12 ...which is how the treeview starts off - at the moment with tv.sort I can only get it to sort back to 1 10 11 - 2 20 21 - etc...

2 Also I need to sort by parents with childs first then parents without like

Expand|Select|Wrap|Line Numbers
  1. 1 Parent
  2.     1 Child
  3.     2 Cild
  4. 3 Parent
  5.     1 Child
  6.     2 Child
  7. 2 Parent
  8. 4 Parent
  9. 5 Parent
Can anyone help please with the logic to sort as described?
Or a link to a sample would be great as I can't find anything.
Many thanks in advance.
Dec 21 '07 #1
3 2300
debasisdas
8,127 Expert 4TB
Are you retrieving data from database to populate the tree control?

If that is the case you can do that using SQL query.
Dec 21 '07 #2
Killer42
8,435 Expert 8TB
Just to let you know Unter, I've put some CODE tags in your post to maintain the indenting. Without them, everything just gets squashed to the left.
Dec 21 '07 #3
Unter
9
Thanks for editing the text for me.

The nodes are added by code from data supplied by the user.
Not from a database. And there are very few, perhaps 15 parent
nodes only and with perhaps 4 of them having two or three children.

Thanks for trying
Dec 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Soul | last post by:
Hi, I am learning C# at the moment. I am trying to develop a simple program that will get data from a MS Access database into a dataSet. The result of dataSet should be something like: Year ...
1
by: Jürgen Müllder | last post by:
Hi! I have a TreeView in my Application. I have the MouseDown Attached to the TreeView. When i click at a Node it makes that what it should. But when i Expand a Node by clicking at the Plus Sign...
4
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
0
by: Ryan | last post by:
I'm doing a recursive function that receives a TreeNode object. It's traversing an XMLDocument and putting the data in a TreeView. The problem is that to start out, I only have a TreeView object....
2
by: DJG | last post by:
I need some help with a TreeView control in VB.Net I've got a datatable with about 8000 rows. 500 are 'folders', and the other 7500 rows are 'jobs'. It's a logical representation of some data,...
2
by: thanneman | last post by:
Hello all, First off all, I appollogize for my englisch. I have a problem. I have a table in my sql database with 2 fields. Field 1 is an ID, and Field 2 contains the complete file locations. ...
1
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
0
by: Unter | last post by:
Hi all My Treeview is working fine with the following layout 1 Parent 2 Parent 1 Child 2 Child 3 Parent
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.