473,654 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGridView column sorting problem

5 New Member
Hey all, I feel like an idiot, but for the life of me I cannot figure out how to do this. Using C#, I have a DataGridView set up with a few thousand rows in it. I need to sort it according to 3 rows. Primarily by one that is a unique numerical value, second and then third by two other columns that can follow the normal sort. Any suggestions on how I go about doing that? Is there any built in functionality for that or am I going to have to manually sort each row.

Thanks
-Steve
Jul 20 '07 #1
1 1465
SammyB
807 Recognized Expert Contributor
The DataGridView sure is complicated! The functionality that you want is there, but you will have to write an IComparer or a SortCompare event handler to implement your sort rule. See the last two examples in http://msdn2.microsoft.com/en-us/lib...08(VS.80).aspx. HTH --Sam
Jul 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
26991
by: rob | last post by:
I have a class that among others exposes a string property "Date". The date in this property is stored in the form yyyymmdd. Now I do the following 1) Generate a DataGridViewTextBoxColumn column for that property 2) Add the column to the datagridview 3) Populate a BindingSource by adding all instances of the above mentioned class. 4) Assign the BindingSource to the datagridview's DataSource property
1
4267
by: cc | last post by:
Hi, using the DataGridView (.NET 2005) : I have a row currently selected in the Grid (say the 3rd row showing 'Product3') Now, when I click on a column to sort the records is the 'Product3' row located as first row in the Grid but not selected (highlighted) anymore. The position of the selected (highlighted)-row doesn't change and is still located on the 3rd row, thus showing a dfifferent product. I don't want
4
8627
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone tell me if this is even possible, and if so, how to do it? If this is completely impossible, how would you suggest going about sorting a ComboBox wherein the text displayed in the column is the client's name, and the underlying value is an ID? ...
0
3906
by: mahesh.nimbalkar | last post by:
I want to use Multi column sorting in DataGridView. The scenario is like this: 1) DataGridView has two columns; Id and name 2) User clicks on Id column and DataGridView is sorted ascending 3) User clicks on Id column and DataGridView is sorted descendin Now, when user clicks on name column, the DataGridView should be sorted as Id desc and name asc.
1
4112
by: PawelR | last post by:
Hi Group, In my application I have DataTable which is displayed in DataGridView via DataView: DataView myView = new DataView(myTable); myDataGridView.DataSource = myView; One column im myTable is boolean (two state - without null value). How can I change value in this column after click on row in datagridview (one of cells in rows).
8
7430
by: Kyote | last post by:
On my form I have a datagridview that's bound to a table on my DB. When I run the app then click on a column header to sort, it sorts just fine. But my problem is a result of that sort. Even though the view has been sorted, it's underlying data isn't. After sorting I'm trying to get the datarow I just doubleclicked on. The problem is it's returning the pre sorted row. That is, the row that was there before I sorted the column. Dim...
4
4787
by: ReneMarxis | last post by:
Hello i have one problem with sorting in an unbound DataGridView. I set sorting to automatic but i get errors when having DBNull values in the column that gets sort ("Object must be of type string"). I solved that problem for one grid/column by fetching the _SortCompare event and doing the sort manualy by seting the SortResult accordingly if its a null value (-1) or not (e.Handled=false;return;) Is there some possibility to specify...
3
4206
by: Frederik | last post by:
Hi group, I have a DataGridView that is mainly consisting of data bound columns. One column however is unbound. I'm not able to sort the grid on this column! Is that normal behaviour? If so, what are my options? Thanks (again) for your time, Frederik
6
4727
by: stocki | last post by:
Hi, On my WinForm I have a DataGridView, which contains four columns and four rows. The last row contains only a sum of the values of the cells of the previous rows in column 3. The cells , , are empty ( ). ="Mr." ; ="Smith" ; ="David" ; =1000 ="Mrs."; ="Fog" ; ="Denise" ; =2000 ="Mr." ; ="Ranger"; ="Stuart" ; =3000
7
20001
Plater
by: Plater | last post by:
I am having trouble determining when my DataGridView object is sorting (based on a column header click). The idea is, in a large table, sorting the columns takes time, so I show a splash screen. When it is done sorting I want the splash screen dissapear. What I had been doing was using the CellClick and Sorted events: private void myDGV_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) {//sorting
0
8285
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
8814
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...
0
8706
jinu1996
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...
1
8475
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
7304
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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
4149
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
2709
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
1592
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.