Solved

How to focus a particular column in a datagridview using VB.NET 2005

Posted on 2009-06-28
2
677 Views
Last Modified: 2013-11-26
Hello Experts,
If I click a button, Then It focuses into a particular column in  a datagridview using VB.NET 2005.
I don't know , How to do it. please help me out
Thanks in advance
0
Comment
Question by:zillion_kamesh
[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
2 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 250 total points
ID: 24734080
This will select the first cell in the second column
Me.DataGridView1.CurrentCell = Me.DataGridView1(1, 0)

Open in new window

0
 
LVL 4

Expert Comment

by:udaydidigam
ID: 24734226
In VB.NET:

Focus a particular cell:

Me.DataGridView1.Rows(0).Cells(0).Selected = true
Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect

Focus a particular column:
      Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.FullColumnSelect
      Me.DataGridView1.Columns(1).Selected = True

Note: When using FullColumnSelect mode, it doesn't allow SortMode of any one column to be set to Automatic

Focus a particular row:
     Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
     Me.DataGridView1.Rows(1).Selected = True
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

730 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