Solved

Datagrid - Deselect selected rows

Posted on 2006-07-06
8
3,326 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
  • 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now