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 1846
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 Windows Server 2003
Enterprise Edition Only.
This works on Windows 2000, Windows 2003 Web Edition and
|
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,
|
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
|
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
|
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
| |
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:
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |