Wrox Programmer Forums
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2009, 07:49 AM
Authorized User
 
Join Date: Jul 2007
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
Default DataGridView default selection.

Hi,
I have a datagrid view whose datasource is a datatable.
When the DGV is first loaded, it selects the first cell of first row by defaut.
This does not change even if I call the ClearSelection method after setting the datasource.
Is this the default behaviour of DataGridView.
If yes then how to handle it.

Regards.
 
Old August 13th, 2009, 08:43 AM
Authorized User
 
Join Date: Jul 2007
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
Thumbs up Solved.

Hi,
I just solved the problem by setting the current cell to null.

Code:
foreach (DataGridViewCell cell in dataGridView1.SelectedCells)
            {
                cell.Selected = false;
            }

            dataGridView1.CurrentCell = null;
I have other issue now.
I have some code in the CellBeginEdit, which I don't want to fire if a column header is clicked.
Any specific condition that can be checked for?





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGridView Use BrianWren Visual Basic 2005 Basics 1 March 5th, 2007 04:34 PM
DataGridView Sakkaw C# 2005 1 January 9th, 2007 12:06 PM
Need Help with datagridview maximus101 VB Databases Basics 2 September 19th, 2006 10:49 AM
Set Default selection in ListBox nmreid Classic ASP Basics 0 January 20th, 2006 04:49 PM
default selection in a datacombo neha_jn VB How-To 4 August 24th, 2004 11:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.