473,394 Members | 1,887 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,394 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 2285
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.