473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

DataGridView : selected-record changes after sorting ???

cc
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
this.

When sorting the records do I want to preserve the selection on the same
record not on the same row.

How can I solve this ?

thnx
Chris
Mar 13 '06 #1
1 4249
Chris, I too have noticed this issue with the DataGridView. Windows
Explorer "remembers" the selected items after a sort, so it would seem
logical that the DataGridView would behave in the same manner. One can
argue whether this rises to the level of a bug, but I believe in the least
it's a design flaw. In any case...

I think the only way to get around this is to do the "remembering" yourself.
As in, before the sort, store all of the selected items, then after the
sort, reselect these items. Maybe someone else can suggest a more elegent
solution whick takes advantage of the native abilities of the DataGridView,
but when I ran into this issue, this solution was what came to mind.

- Mitchell S. Honnert
"cc" <cm****@yahoo.com> wrote in message
news:44***********************@news.skynet.be...
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
this.

When sorting the records do I want to preserve the selection on the same
record not on the same row.

How can I solve this ?

thnx
Chris

Mar 13 '06 #2

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

Similar topics

0
by: GS | last post by:
Hi, I have dataGridView with MultupleSelect property enabled and I programmatically set rows to be Selected based on checkbox being selected in DataGrid (code below). Issue is that it resets...
3
by: Karl Rhodes | last post by:
I have a datagridview which is populated via a datatable. What I would like to dynamically set a selected row and have that row show up in the datagridview and not have to manually scroll to find...
7
by: randy1200 | last post by:
I have some buttons that increment and decrement the index of a DataGridView. The code below gets the updated index value. The code below highlights the first column of the current row. ...
1
by: Riley | last post by:
Need some help. I am using datagridview in 2005 with C#. I am calling a web service and filling the datagridview with the data returned. This all works fine. Next step is to take a value from one...
2
by: Lennart | last post by:
Hi I have a DataGridView on a Form filled with data from a DataTable. When I Load this form I want to select a row in the DataGridView depending on a selected Primary Key index; How do I do...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
2
by: colin | last post by:
Hi, I need to tell how many rows are visible on the screen, in my DataGridView control so that I can ensure my newly selected row is visible without doing any unecessry scrolling, I thought...
6
by: hzgt9b | last post by:
Using VS2005, VB.NET, I have a windows app with a DataGridView (lets call it DGV). At some point in the life of my app I want to clear the selection of the currently selected row...
0
by: =?Utf-8?B?QXR1bCBSYW5l?= | last post by:
Hi, I am using datagridview when, I am assigning datasource to Datagridview i am gettin exception "Child list for field Region cannot be created." I am Assigning Collection as a datasource to...
5
by: BabliS1 | last post by:
I am using Vb.net2005. I have a datagridview which displays some data. I want to filter the records based on some criteria given by the user at runtime. How can I do this. Please Help. Thanks in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.