[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

vb.net datagridview column name instead of column index

Posted on 2010-11-08
2
Medium Priority
?
1,098 Views
Last Modified: 2012-05-10
How can replace Cells.Item(0).Value for column name, something like cells("columnname")

DgvDetalhe.Rows.Item(e.RowIndex).Cells.Item(0).Value
0
Comment
Question by:rflorencio
[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 13

Assisted Solution

by:gamarrojgq
gamarrojgq earned 600 total points
ID: 34085752
Hi,

Just like this

DgvDetalhe.Rows.Item(e.RowIndex).Cells("YOURCOLUMNAEHERE").Value
0
 
LVL 15

Accepted Solution

by:
x77 earned 1400 total points
ID: 34085978
You can use ColumnName or ColumnIndex to access a Cell on a DataRowView.

But .... Note that  AutoGenerated  Column Names for DataGridView take names like:
 
   DataGridViewTextBoxColumn1 ...

I use DataColumn.Index to allow refactoring.

If you have a collumn named DataGridViewTextBoxColumn1 and you rename it to OrderIdCol using Ide Refactoring option, then

Any sentence like
   Dgv.Rows(n).cells(DataGridViewTextBoxColumn1.Index).Value    is ajusted to
   Dgv.Rows(n).cells(OrderIdCol.Index).Value

Also you can find any line that uses OrderIdCol with refactoring.

I never use Strings to access DataGridviewColumns.  I like Refactoring options.
 
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

656 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