473,609 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in listview sorting vb.net 2005 enterprise edition

2 New Member
hi all,
I want to sort the colum when clicks the columnheader using vb.net 2005 .But i receive the following error
"Error 1 Overload resolution failed because no accessible 'New' accepts this number of arguments. "

and my code is
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick
  3. If e.Column <> sortColumn Then 
  4. sortColumn = e.Column
  5. ListView1.Sorting = SortOrder.Ascending ' asc by default 
  6.  
  7. If ListView1.Sorting = SortOrder.Ascending Then
  8. ListView1.Sorting = SortOrder.Descending
  9. Else
  10. ListView1.Sorting = SortOrder.Ascending
  11. End If
  12.  
  13. ListView1.Sort()
  14. Dim sorted As New classSorter(e.Column, ListView1.Sorting)
  15. ListView1.ListViewItemSorter = sorted
  16.  
  17. End If
  18.  
  19. End Sub
  20.  
  21. Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
  22.  
  23. End Sub
  24. End Class
  25.  
  26. Public Class classSorter
  27. Implements IComparer
  28.  
  29. Private col As Integer ' column to sort 
  30. Private order As SortOrder ' asc or desc 
  31.  
  32. Public Sub New()
  33. col = 0 ' sort first col by default in ascending order 
  34. order = SortOrder.Ascending
  35. End Sub
  36.  
  37. ' c-tor that receives column to sort and in which order 
  38. Public Sub New(ByVal aColumn As Integer, ByVal order As SortOrder, ByVal aForm As Form)
  39. col = aColumn
  40. Me.order = order
  41. End Sub
  42.  
  43. ' method to compare two objects (list view items) 
  44. Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
  45.  
  46. Dim returnVal As Integer = -1
  47.  
  48. Dim xItem As System.Windows.Forms.ListViewItem = x
  49. Dim yItem As System.Windows.Forms.ListViewItem = y
  50.  
  51. Select Case col
  52. Case 0 ' in this case 0th column holds numerics 
  53. ' sort numeric values 
  54. Dim blnCompare As Boolean
  55.  
  56. blnCompare = Val(xItem.SubItems(col).Text) > Val(yItem.SubItems(col).Text)
  57.  
  58. If blnCompare Then
  59. returnVal = 1
  60. Else
  61. returnVal = -1
  62. End If
  63.  
  64. Case 1 ' in this case 1th column holds strings 
  65. ' sort strings 
  66. returnVal = [String].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text)
  67.  
  68. Case 2 '' in this case 2nd column holds datetime vals 
  69. ' sort date time values 
  70. returnVal = DateTime.Compare(CDate(xItem.SubItems(col).Text), CDate(yItem.SubItems(col).Text))
  71.  
  72. Case 3
  73. returnVal = DateTime.Compare(CDate(xItem.SubItems(col).Text), CDate(yItem.SubItems(col).Text))
  74.  
  75. Case 4 '' in this case 0th column holds numerics 
  76. ' sort numeric values 
  77. Dim blnCompare As Boolean
  78.  
  79. blnCompare = Val(xItem.SubItems(col).Text) > Val(yItem.SubItems(col).Text)
  80.  
  81. If blnCompare Then
  82. returnVal = 1
  83. Else
  84. returnVal = -1
  85. End If
  86.  
  87. Case Else
  88.  
  89. End Select
  90.  
  91. ' is sort order descending 
  92. If order = SortOrder.Descending Then
  93. ' ivert the value returned by string.compare. 
  94. returnVal *= -1
  95. End If
  96.  
  97. Return returnVal
  98. End Function
  99.  
please help me...i need the solution very urgent.....
Jul 17 '08 #1
4 1846
DrBunchman
979 Recognized Expert Contributor
Hi rajtalent,

I've editied your post above to surround your code with [code] tags - please use the # button in the edit window to do so in future.

Which line are you receiving the error on?

Dr B
Jul 17 '08 #2
rajtalent
2 New Member
Hi rajtalent,

I've editied your post above to surround your code with [code] tags - please use the # button in the edit window to do so in future.

Which line are you receiving the error on?

Dr B

Hi Dr B
Sorry for inconvenience.. .I got an error in line no.13..."sorted" highlighted as error..please give me solution
Jul 17 '08 #3
DrBunchman
979 Recognized Expert Contributor
Hi rajtalent,

Have you been able to fix your problem yet?

Dr B
Jul 22 '08 #4
Curtis Rutland
3,256 Recognized Expert Specialist
Well, you've defined two constructors (the "New" subs): one with no arguments, and one with three. On line thirteen, you are trying to instantiate a new object with only two arguments:

line 31 constructor with no arguments
Expand|Select|Wrap|Line Numbers
  1. Public Sub New()
  2.     col = 0 ' sort first col by default in ascending order
  3.     order = SortOrder.Ascending
  4. End Sub
  5.  
' line 37 constructor with three arguments
Expand|Select|Wrap|Line Numbers
  1. Public Sub New(ByVal aColumn As Integer, ByVal order As SortOrder, ByVal aForm As Form)
  2.     col = aColumn
  3.     Me.order = order
  4. End Sub
  5.  
'line 13, where you instantiate with only two arguments:
Expand|Select|Wrap|Line Numbers
  1. Dim sorted As New classSorter(e.Column, ListView1.Sorting)
  2.  
So either you made a mistake in your constructor, or in your declaration.
Jul 22 '08 #5

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

Similar topics

1
3151
by: Keith | last post by:
All, I have been told this is an ASP.NET issue and not an IIS issue, so I am posting this here. I have a problem with ASP.NET returning an HTTP 500 error when trying to run ASPX pages on Windows Server 2003 Enterprise Edition Only. This works on Windows 2000, Windows 2003 Web Edition and
4
2409
by: mcwooq | last post by:
Hi, I just installed the VS.Studio 2005 Team Edition for Developper and encountered severe problems with debugging ASP.NET 2.0 projects. Even newly empty created ASP 2.0 projects can't debug (setting breakpoint in page_load()). I'm getting the following message: "Unable to start debugging on the web server. An error occurred that usually indicates a corrupt installation (code 0x80004002). If the problem persists,
6
4790
by: Dave | last post by:
VB6 has a SorkKey property that you can setup on the ListView control to tell the ListView what column to use for sorting. In .NET there is a Sort() method and a SortOrder property that you can use to manipulate the Sorting property. My question is how do I perform the same functionality as I do in VB6 setting the SortKey and SortOrder with the ListView. Dave
42
6726
by: Paul | last post by:
Anyone know where I can find some good resources to help us choose between SQL and Oracle ( Progress Openedge as well ) . Any comments on what you would choose ?? We are creating a new Warehouse Management System which wil manage our very large inventory. Anyway comments suggestions welcome Thanks Paul
23
14022
by: Nishant Saini | last post by:
Dear All, We have a database which contains many tables which have millions of records. When We attach the database with MS SQL Server 2005 Standard Edition Server and run some queries (having joins, filters etc.) then they take very long time to execute while when We execute same queries on Enterprise Edition then they run 10 times faster than on standard edition. Our database does not use any features which are present in Enterprise
2
10858
by: thersitz | last post by:
Hi, I have VStudio2005, SQLServer 2005 dev edition loaded on a windowsXP Pro machine. I installed it ok. I just attempted to load the Personal Web Site Starter Kit (I downloaded off Microsoft's site) to use with VStudio 2005 -- Installing it from the MS site failed without any error messages. When I used VSTudio to open, it loaded ok, but when I went to view the default.aspx page I got this error:
4
1918
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
We have to upgrade our Visual Studio .NET 2003 enterprise edition to .NET 2005. However, there is no enterprise edition for Visual Studio .NET 2005. There are 4 versions available for visual studio team edition 2005, Software Architect, Software Developer, Software Tester, and Team Suite which includes all three architect, developer, and tester. There are also professional and standard. Which is one is equivalent to Visual Studio .NET...
14
2640
by: Guillermo_Lopez | last post by:
Hello, Our company has developed several Access applications for our clients and we wish to expand to use a database server. We wish to use Access as the front end application and SQL Server 2005 as the back end Databes Server. Making a Server-Client application database. I'm very new to SQL Server so my concern is how the licensing works for a developer like us. I am aware that we can purchase the Developer edition for $49 USD. Our...
0
8109
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8509
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8188
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8374
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4002
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4059
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2502
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.