Matt Anderson gave me something to work on, he stated “Here’s a suggestion – Parcel Volume Report – add a bubble sort to sort the parcel report by number.” I don’t like bubble sorts, too confusing, so I went with another way to tackle the problem. In my solution I make the columns sortable. To do this I heavily leaned on this MSDN article (meaning I copied and modified it).
I think this only will work with Visual Studio 2008 and isn’t applicable for Visual Studio 2005. There is another article in MSDN that covers the older version of Visual Studio. (Meaning this would work only for Civil 3D 2010 and not an earlier version)
The first thing you have to do is copy the source code to the reports to a new location. The source code is located at: C:\ProgramData\Autodesk\C3D 2010\enu\Data\Reports\Net\Source (at least for Windows 7)
Next open the Solution (C3DReports.sln) in Visual Studio 2008. Do a search (Ctrl+F) for “li.SubItems.Add(oParcel.Parent.Name” and it should take you to one of two places in the code. Make sure you are in the ReportForm_ParcelVol.vb. In the code above the “For Each oSite…” add the following:
' Suspend control logic until form is done configuring form.
Me.SuspendLayout()
' Set the initial sorting type for the ListView.
ListView_Parcels.Sorting = SortOrder.None
After the Second Next add the following:
' Connect the ListView.ColumnClick event to the ColumnClick event handler.
AddHandler ListView_Parcels.ColumnClick, AddressOf ColumnClick
Now we need to add the column click event handler and the ListViewItemComparer Class. The ListViewItemComparer Class will sort the column. All of the revised code is highlighted in yellow below:
So now when you click on a column the items in the list will be sorted in numerical order. If I used this report often, I’d probably add the capability to select which sites are added to the list. Maybe a post for another day.
To finish this up compile the code by going to Build on the Menu bar and choosing to Build C3DReports. Copy the file from the obj/bin/build/ folder and then overwrite the original report .dll (after backing up the original file).
I’ve got an Office product on my machine that most of you probably don’t have otherwise I would have posted a revised .dll, but to make it easier here’s the revised class. Just unzip, replace the original class and recompile the code.
This post has been revised: http://blog.civil3dreminders.com/2009/08/parcel-volume-report-sorting-revised.html
Also I’m still looking for trades, so make an offer!