[.NET] Sorting entities?

[.NET] Sorting entities?

Anonymous
Not applicable
853 Views
3 Replies
Message 1 of 4

[.NET] Sorting entities?

Anonymous
Not applicable

Hello everyone !

 

I've a little problem with the sorting of entities.

 

In my project, i've a listbox, with the names of every ent on the drawing in autocad (If i draw 1 lines, 1 circle, and 1 spline, i've LINE, CIRCLE, SPLINE in my listbox) and i've also a list of ID with each entity ID. And i've also a button that imports data from the drawing (it imports names and ID of each entities, from the first ent  that was drawn, to the last one and put it in the listbox)

 

My problem is pretty simple. I want to "sort" entities with a button UP and a button DOWN.

(imagine i've a list like : LINE, CIRCLE, SPLINE  , if i select CIRCLE and click on the button UP, my list become CIRCLE, LINE,SPLINE, and also change it on autocad (maybe by the ID?), so that if i get the datas again, it's in the order i've decided before)

 

it's easy to swap items in the listbox, but how to do it in autocad ? (i guess i have to make some change in the tablerecord, or something like this.)

 

Someone has already done something like this?

 

Thanks for your help.

 

Adri Dicri

 

PS : Sorry for my horrible english, french is my mother tongue.

 

 

 

 

 

0 Likes
Accepted solutions (1)
854 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Hi Adri,

 

I would first sort the list using the .net :

 

        Dim SO As System.Windows.Forms.SortOrder

        SO = Windows.Forms.SortOrder.Ascending
        ListView1.Sorting = SO

 

Then I would read the list into an Array, sort it the way I want and order.

then read the Array back into the clean ListBox

 

-Jay

0 Likes
Message 3 of 4

chiefbraincloud
Collaborator
Collaborator
Accepted solution

Start here:

http://through-the-interface.typepad.com/through_the_interface/2007/03/manipulating_th.html

 

The article shows how to use the DrawOrderTable.  It only demonstrates the MoveToBottom method, but there are also MoveAbove, MoveBelow, and I think the one you will end up using the most will be SwapOrder.

 

Dave O.                                                                  Sig-Logos32.png
0 Likes
Message 4 of 4

Anonymous
Not applicable

Thanks for your help it was very usefull !

 

I resolve the problem with "SwapIdWith(...)"

 

Your link pointed me on the right direction.

 

Thanks a lot.

 

Adri DiCri

0 Likes