473,789 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorted ListView throws exception

Hi. I subclassed a ListView to give it the capability to sort by a column when the column header is clicked and it works fine. The problem is when the listview gets refreshed, all items are cleared and then read from the database and the listview is repopulated. Here it throws an exception when the 2nd item is added to the listview, apparently because it tries to compare it with the first to sort them out. Is there an easy way to sort a listview? It used to be built in VB6. I appreciate any help about this or information

Thanks in advance
Nov 20 '05 #1
1 1113
* "=?Utf-8?B?UmljaGFyZA= =?=" <e_**********@h otmail.com> scripsit:
Hi. I subclassed a ListView to give it the capability to sort by a
column when the column header is clicked and it works fine. The problem
is when the listview gets refreshed, all items are cleared and then read
from the database and the listview is repopulated. Here it throws an
exception when the 2nd item is added to the listview, apparently because
it tries to compare it with the first to sort them out. Is there an easy
way to sort a listview? It used to be built in VB6. I appreciate any
help about this or information.


What exception?

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2027
by: Tom | last post by:
For some strange reason my WinForms app occasionally throws a System.NullReferenceException upon invoking the Clear() method. The app will work fine for a long period of time and then all of a sudden this exeption is thrown and after that you just cant ever clear the ListView control again - even though messages still go into it and are displayed correctly. Anybody have any idea what could be causing this?
2
3380
by: Aron Henning | last post by:
I have a ListView that contains the subfoldes of a local drive. Whan i click on a subfolder the listbox should display the subfolders of this folder instead. the funktion is as follows: private void FolderList_SelectedIndexChanged(object sender, System.EventArgs e) { try
1
3791
by: Brian Keating EI9FXB | last post by:
Hello there, I've been playing with custom draw and am having a bit of difficulty, Namely the graphics function in this function throws invalid arg exception. Im pretty sure this is correct cause the rect part of the nmcd seems to be nonsence public int OnItemPrePaint(int idCtrl, ref Win32.NMCUSTOMDRAW nmcd) { using (Graphics gdc = Graphics.FromHdc(nmcd.hdc)){ gdc.ReleaseHdc(nmcd.hdc);
4
2238
by: Ira Siyal | last post by:
Hi I had a project in VB6 which I upgraded to VB.NET recently. In the app, I am facing some issue with listview control. In the earlier app, I have set the Icons in listview through an imagelist. but i notice that while i execute the project in .net, the step that sets the icon prop. throws an exception.
7
15009
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
0
1974
by: Stuart | last post by:
Hi, I am trying to use a 2.0 virtual listview, I thought it was all working fine until I tried to remove an item from it. For example if the top of the list is visible and I do: myListView.VirtualListSize = myListView.VirtualListSize - 1; It works fine, the scrollbar shrinks slightly so it's obvious the bottom has been removed, but if the scrollbar is moved down slightly at all the line
0
1558
by: =?Utf-8?B?Q2FibGVHdXk=?= | last post by:
If I have an unsorted listview I know I can select the first Item by ListView.Items.Selected = true. How do I select the first item in a sorted listview? Thanks. CableGuy
4
13165
by: forest demon | last post by:
I have an IList/Collection that contains items in a ListView. If i click on an item in the ListView, i can capture the index (lv.SelectedItems.Index) and reference the correct item in the associated IList/Collection . Once I've sorted the ListView, obviously the indices do not match up anymore. So, should i sort the IList/Collection when I sort the ListView (which seems overkill to me) or some how sort the indices associated with the...
5
229
by: Joza | last post by:
Hi! I'm getting error when selecting items in ListView control, it says ArguementOutOfRangeExceptions. That happens in SelectIndexChange event. I have tryed with try...catch but there's no effect. The code inside that event is: private void LVKalk_SelectedIndexChanged(object sender, System.EventArgs e) { try
0
9663
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...
1
10136
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
9979
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...
1
7525
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
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
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
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
3
2906
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.