Solved

Datagrid - Deselect selected rows

Posted on 2006-07-06
8
3,336 Views
Last Modified: 2008-01-09
I have a datagrid that allows the user to select multiple rows.
The datasource for the grid is a table.

I would like to Deselect the selected row(s) when the user clicks on a command key.

Just as if he clicked on another row.

Help would be very much appreciated.

Thanks,
Ed
0
Comment
Question by:SSSoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 7

Expert Comment

by:rohanbairat3
ID: 17053969
0
 
LVL 7

Expert Comment

by:rohanbairat3
ID: 17053982
0
 
LVL 5

Expert Comment

by:nickhoggard
ID: 17056305
Hi, Is it a datagrid or a datagridview?

If DataGridView:

For each objRow as DataGridViewRow in dataGridView1.SelectedRows
    objRow.Selected = False
Next

Cheers

Nick
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:SSSoftware
ID: 17058875
Nick,

Thanks for bring up the DataGridView.

I have been working in a vacuum for the last year.

I'll look into using it. It could solve many of my other (not-So-Nice) problems that I'm having with the standard datagrid.

I'm having problems finding the DOWNLOAD site for the DataGridView Control. If you have it could you point me to it.

Ed
0
 
LVL 5

Expert Comment

by:nickhoggard
ID: 17062264
Hi,

The datagridview is part of the .NET 2.0 framework, which probably would have been the better question for me to have asked you (which framework are you building on?).  I'm guessing that since you do not have it in your toolbox you are probably building on .NET 1.1, therefore my solution won't be any help to you sorry :-(

Do you bind to a datasource for the grid?  If so this might work for the .NET 1.1 version (this is just free hand) :

        ' You might need a different syntax for getting the count, depending on your datasource
        For i As Integer = 0 To DataGrid1.DataSource.Count - 1
            DataGrid1.UnSelect(i)
        Next

Hope this helps

Cheers

Nick
0
 
LVL 4

Author Comment

by:SSSoftware
ID: 17080967
Nick,

So far no good, There is not an UNSELECT method  (or anything like it) available.  

We will go to 2.0 as soon as most of our development is complete. We just don't want to change in the middle of development and we have 4 other products that should be upgraded at the same time.  


Ed
0
 
LVL 5

Accepted Solution

by:
nickhoggard earned 200 total points
ID: 17084555
Hi Ed,

I only wrote that example from what I saw in the MSDN library, since I dont have .NET 1.1 installed any more.

The page I was referencing is below, and it does seem to indicate that unselect is an option:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagrid.unselect.aspx

Beyond that, I'm sorry I probably can't be of much more help without having the specific framework installed here.

Nick
0
 
LVL 4

Author Comment

by:SSSoftware
ID: 17114713
Nick,

Thank You....
It works great.
I have completly missed unselect when I was searching.

I appreciate your help.

Ed
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question