473,408 Members | 1,784 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,408 software developers and data experts.

Error in listview sorting vb.net 2005 enterprise edition

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 1834
DrBunchman
979 Expert 512MB
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
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 Expert 512MB
Hi rajtalent,

Have you been able to fix your problem yet?

Dr B
Jul 22 '08 #4
Curtis Rutland
3,256 Expert 2GB
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
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...
4
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...
6
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...
42
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...
23
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...
2
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...
4
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...
14
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.