473,669 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting DataGridView

DataGridView allows the user to sort data by clicking a column header. Can
someone tell me how I can configure the control so that the first column is
by default sorted ascending?

Thankyou

Pete
Sep 29 '07 #1
2 1572
Hi Peter,
check this out !
http://msdn2.microsoft.com/en-us/library/0868ft3z.aspx

http://msdn2.microsoft.com/en-us/lib...view.sort.aspx
Regards,
Husam Al-A'araj
www.aaraj.net
"Peter Morris" wrote:
DataGridView allows the user to sort data by clicking a column header. Can
someone tell me how I can configure the control so that the first column is
by default sorted ascending?

Thankyou

Pete
Sep 29 '07 #2
Just what I needed, I didn't see that subject when I looked on the site.
Shukran!
Pete
Sep 30 '07 #3

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

Similar topics

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
3
6624
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be implemented simultaneously for multiple columns - but the data need only be sorted by a single column at a time. Sorting should be both ascending and descending. I'm currently using a DataView but it's far too slow, because there are a large...
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
9669
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using a DataGridView on a Form. I want to disable the clicking on the columns headers to disallow the sorting. How can I do that, but without deriving the DataGridView? Is there any other way to disable the sorting of the DataGridView without deriving it?
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...
1
2172
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns (LoginName,UserName) 2. the datagridview sorting is set to automatic, so when i click on the column header is sorts well. 3. i put in an event handler for the CellEndEdit Event, so whenever the user of the program changes the content of a cell in the LoginName...
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...
6
4728
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
20004
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
1494
by: Queez | last post by:
OK, this is rediculous... Surely, sorting should be one of the easiest things with the ASP.NET DataGridView control. I mean, there's hundreds of sites out there (Microsoft MSDN entries included) which explain and give examples of the DataGridView sorting and how to make it work... SO WHY CAN'T I GET IT TO WORK?! Dammit! Apologies for the rant. I'll try and keep it to the point from here on in: I have tried the following:
0
8465
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...
0
8383
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
8894
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
8658
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...
0
7407
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
6210
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
4206
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...
2
2029
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
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.