473,666 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListChanged event?

When sorting a datagrid by clicking its column header, a ListChanged event is
raised by the dataview on that the datagrid is based. However, inside the
ListChanged event handler, I loop through the dataview and see that the order
of the dataview is not changed.
I have a SequenceNumber column in that dataview and wish to reset the column
when the datagrid is sorted. I don't want to loop through the datagrid, it's
slow.
Any suggesstions, thanks.
Nov 21 '05 #1
1 1844
To sort a dataview, set the dataview.sort property to the mapping name of the
column that you want to sort on. When the user clicks on a column header,
get the mapping name and pass it to the sort property.

You can use sort using multiple columns separated by commas, and you can set
each column to ASC or DESC, with ASC as default.

dataview.sort = "colA"
OR
dataview.sort = "colA, colB DESC"

Also, getting the column name can be a little tricky. I found this code in
a recent project. It assumes you are using TableStyles and ColumnStyles. If
not, you could set up an association of datagrid column indices and dataview
column names with an ArrayList and alter the code below.

Private Sub DataGrid1_Mouse Down(ByVal sender As System.Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles DataGrid1.Mouse Down
Dim HTI As DataGrid.HitTes tInfo = DataGrid1.HitTe st(e.X, e.Y)
Select Case HTI.Type
Case DataGrid.HitTes tType.ColumnHea der
Dim ColName As String =
DataGrid1.Table Styles(0).GridC olumnStyles(HTI .Column).Mappin gName
Dataview1.sort = ColName
Case ...
End Select
End Sub
www.charlesfarriersoftware.com

"John" wrote:
When sorting a datagrid by clicking its column header, a ListChanged event is
raised by the dataview on that the datagrid is based. However, inside the
ListChanged event handler, I loop through the dataview and see that the order
of the dataview is not changed.
I have a SequenceNumber column in that dataview and wish to reset the column
when the datagrid is sorted. I don't want to loop through the datagrid, it's
slow.
Any suggesstions, thanks.

Nov 21 '05 #2

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

Similar topics

0
7035
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
18
2877
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
0
1133
by: tolisss | last post by:
Hi to all i have some validation code inside ListChanged event and i have that collection bound to a grid. If i change a value on the grid the event fires ok. But if i change a value of the collection directly the event does not fire :(. Is that standard behaviour? *---------------------------------* Posted at: http://www.GroupSrv.com Check: http://wwww.HotCodecs.com *---------------------------------*
8
6084
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that uses message queues to pass pointers to Events between threads. In my app there are simple events that can be defined using an enum (for example an event called NETWORK_TIMEOUT) and more complex events that contain data (for example an event called...
0
1393
by: Bijoy | last post by:
After Binding a Custom Collection as a Datasource , how is it possible to remove the references in the Property event ListChanged implemented by the IBindingList interface in our Custome collections. At the moment this is causing a bit of a worry since there ar Non-serializable references in the Property Listchanged eg. System.Windows.Forms.CurrencyManager and hence we arent able to pass our collection back to other layers (physically...
11
2903
by: Alx Sharp | last post by:
Hello group... I've created a collection class that implements the following interfaces: IBindingList, IList, ICollection, IEnumerable and ITypedList: abstract class DataCollectionBase : IBindingList, IList, ICollection, IEnumerable, ITypedList { private ArrayList innerList = null; private System.Type itemType = null; public DataCollectionBase()
41
4288
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. I'm not using the VB toolbar because of limitations in changing things like backcolor (I can't get...
0
1715
by: Ray Holiday | last post by:
Hi, I'm using the DataView.ListChanged event to catch modifications to my table. But every time I update a row in my table the event fires has many time has I have columns. Since I have 55 columns and sometimes can be sending 3 updates within the same second, the event fires close to 170 times in the same second. I would like to received only one update notification per row rather than for every Item. I am using the...
9
2465
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the post event will always execuate after the system is completed... - I want to wrap this functionality in a framework, so I could possibly have 3 or 4 levels of inherited objects that need to have these pre / post events executed before and after the...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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...
1
8552
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
8640
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
6198
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
4198
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...
1
2773
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
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.