Solved

Datagrid - Deselect selected rows

Posted on 2006-07-06
8
3,333 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Import a txt file into a DataGridView and TextBox 20 52
get column names from table in vb.net 8 49
Iteration Help (Asp.net VB) 5 24
Convert Ctime to date time in textfile? 7 32
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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