how to find the column index of a column in Datagridview? I want to be able to select an data element by myDGV[columnIndex, rowIndex] - Edited byfs - new to w7 Wednesday, August 19, 2009 6:38 PM
-
| | fs - new to w7 Wednesday, August 19, 2009 6:11 PM | thank you, NareshG.That helps me get it right.
To get the value of cell: myDGV[columnIndex , rowIndex].value
where columnindex can actually be a number or a column name and
To get the index of a column myDGV.Columns.IndexOf(myDGV.Columns["SampleColumn"];
or more simply like yousaid myDGV.Columns["SampleColumn"].Index;
- Edited byfs - new to w7 Friday, August 21, 2009 3:36 AMupdate for better detail and explaination
- Marked As Answer byfs - new to w7 Wednesday, August 19, 2009 11:29 PM
-
| | fs - new to w7 Wednesday, August 19, 2009 11:29 PM | They are sequential starting at 0. So to select the second column, it would be column index of 1. Depending on where you want to do this, some of the events also provide information on the current column. Hope this helps. www.insteptech.com ;
msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS! | | DeborahK Wednesday, August 19, 2009 7:23 PM | Hello fs, To access data, you should know column index or column Name, if you know any one then you can select like, 1) myData[columnIndex , rowIndex] 2) myData[ColumnName ,rowIndex] Or if you want to find column index , myData.Columns.IndexOf(/*DataGridViewColumn*/) myData.Columns[/*ColumnName*/].Index
| | NareshG Wednesday, August 19, 2009 7:30 PM | thank you, NareshG.That helps me get it right.
To get the value of cell: myDGV[columnIndex , rowIndex].value
where columnindex can actually be a number or a column name and
To get the index of a column myDGV.Columns.IndexOf(myDGV.Columns["SampleColumn"];
or more simply like yousaid myDGV.Columns["SampleColumn"].Index;
- Edited byfs - new to w7 Friday, August 21, 2009 3:36 AMupdate for better detail and explaination
- Marked As Answer byfs - new to w7 Wednesday, August 19, 2009 11:29 PM
-
| | fs - new to w7 Wednesday, August 19, 2009 11:29 PM | hi fs, You should give credit to the folks who answer your questions. If my above post answer your question then , please mark it as answer.
| | NareshG Thursday, August 20, 2009 7:12 PM | Thank you NareshG again. I already thank you in the post immediately following your post. " thank you. that helps get it right"
I would have marked your post as answer except I could not getall compile without error. So I tried to give you credit and mark your post as helpful.
it was not just customery thank you but a real heart felt thank you.Sorry that I didnot put in some extra words to make it stand out and make you feel good.
Thank you again.
PS. if you feel like, you can post a sample that would compile w/o error and easy for beginner and for people that don't have as much smart as someothers to understand w/o guessing, I would try mark that as answer.... Also if you find error in my example, I will umark mine when you have a complete working sample post
I admit that I'm far from being smart. when it comes to visual studio and dotnet, I'm pretty close to being ignorant if not shallow - Edited byfs - new to w7 Thursday, August 20, 2009 11:40 PM
- Edited byfs - new to w7 Friday, August 21, 2009 3:29 AM
-
| | fs - new to w7 Thursday, August 20, 2009 11:37 PM |
|