DataGridView Problem getting Column and Row Number

Posted on 2008-02-11
Medium Priority
Last Modified: 2013-11-26
I have always used the Standard .net Datagrid but need to use the Datagridview on this occassion.  My problem is simple but I have spent several hours on it so not that simple to me.  In a datagrid to find the current column I always used datagrid.currentcell.columnnumber or datagrid.currentcell.rownumber.
These don't exist for datagridview so I thought i'd try datagridview.currentcell.columnindex but I always get 0.

I have my grid setup with around 20 rows and 60 columns but just cannot find the column or row number.

I know it must be simple but I need your help.

Question by:TimBPowell
  • 3
LVL 48

Accepted Solution

Jorge Paulino earned 1500 total points
ID: 20865943
Hi TimBPowell,

You can use

LVL 48

Expert Comment

by:Jorge Paulino
ID: 20865951
Y = rowindex
X = columnindex

All zero based
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20865968
DataGridView1.CurrentCell.ColumnIndex works fine for me. You might also like to try DataGridView1.CurrentCellAddress.X
LVL 48

Expert Comment

by:Jorge Paulino
ID: 20865986
>> DataGridView1.CurrentCell.ColumnIndex works fine for me

For me too webtubbs

Author Closing Comment

ID: 31429773
Thanks for your help.  Thought it was easy.  Just had brain lock this morning!

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
SingleRun is a tool that ensures that only one instance of an application is started, running it again brings the application to focus.
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

587 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