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 -
-
Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick
-
If e.Column <> sortColumn Then
-
sortColumn = e.Column
-
ListView1.Sorting = SortOrder.Ascending ' asc by default
-
-
If ListView1.Sorting = SortOrder.Ascending Then
-
ListView1.Sorting = SortOrder.Descending
-
Else
-
ListView1.Sorting = SortOrder.Ascending
-
End If
-
-
ListView1.Sort()
-
Dim sorted As New classSorter(e.Column, ListView1.Sorting)
-
ListView1.ListViewItemSorter = sorted
-
-
End If
-
-
End Sub
-
-
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
-
-
End Sub
-
End Class
-
-
Public Class classSorter
-
Implements IComparer
-
-
Private col As Integer ' column to sort
-
Private order As SortOrder ' asc or desc
-
-
Public Sub New()
-
col = 0 ' sort first col by default in ascending order
-
order = SortOrder.Ascending
-
End Sub
-
-
' c-tor that receives column to sort and in which order
-
Public Sub New(ByVal aColumn As Integer, ByVal order As SortOrder, ByVal aForm As Form)
-
col = aColumn
-
Me.order = order
-
End Sub
-
-
' method to compare two objects (list view items)
-
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
-
-
Dim returnVal As Integer = -1
-
-
Dim xItem As System.Windows.Forms.ListViewItem = x
-
Dim yItem As System.Windows.Forms.ListViewItem = y
-
-
Select Case col
-
Case 0 ' in this case 0th column holds numerics
-
' sort numeric values
-
Dim blnCompare As Boolean
-
-
blnCompare = Val(xItem.SubItems(col).Text) > Val(yItem.SubItems(col).Text)
-
-
If blnCompare Then
-
returnVal = 1
-
Else
-
returnVal = -1
-
End If
-
-
Case 1 ' in this case 1th column holds strings
-
' sort strings
-
returnVal = [String].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text)
-
-
Case 2 '' in this case 2nd column holds datetime vals
-
' sort date time values
-
returnVal = DateTime.Compare(CDate(xItem.SubItems(col).Text), CDate(yItem.SubItems(col).Text))
-
-
Case 3
-
returnVal = DateTime.Compare(CDate(xItem.SubItems(col).Text), CDate(yItem.SubItems(col).Text))
-
-
Case 4 '' in this case 0th column holds numerics
-
' sort numeric values
-
Dim blnCompare As Boolean
-
-
blnCompare = Val(xItem.SubItems(col).Text) > Val(yItem.SubItems(col).Text)
-
-
If blnCompare Then
-
returnVal = 1
-
Else
-
returnVal = -1
-
End If
-
-
Case Else
-
-
End Select
-
-
' is sort order descending
-
If order = SortOrder.Descending Then
-
' ivert the value returned by string.compare.
-
returnVal *= -1
-
End If
-
-
Return returnVal
-
End Function
-
please help me...i need the solution very urgent.....
4 1834
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 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
Hi rajtalent,
Have you been able to fix your problem yet?
Dr B
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 -
Public Sub New()
-
col = 0 ' sort first col by default in ascending order
-
order = SortOrder.Ascending
-
End Sub
-
' line 37 constructor with three arguments -
Public Sub New(ByVal aColumn As Integer, ByVal order As SortOrder, ByVal aForm As Form)
-
col = aColumn
-
Me.order = order
-
End Sub
-
'line 13, where you instantiate with only two arguments: -
Dim sorted As New classSorter(e.Column, ListView1.Sorting)
-
So either you made a mistake in your constructor, or in your declaration.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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: 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...
|
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...
| |