Problem with columns in DataGridView
-
Im trying to access a certan column in a data bound DataGridView like this. int index = (int)dataGridView1.Columns["SomeColumn"].DisplayIndex; But some how i allways got the "dataGridView1.Columns["SomeColumn"]" to be null. That is it is not set to an object. But if i use the syntax int index = (int)dataGridView1.Columns[0].DisplayIndex it works fine! Any ideas? Ive got nothing :) Thankz
-
Im trying to access a certan column in a data bound DataGridView like this. int index = (int)dataGridView1.Columns["SomeColumn"].DisplayIndex; But some how i allways got the "dataGridView1.Columns["SomeColumn"]" to be null. That is it is not set to an object. But if i use the syntax int index = (int)dataGridView1.Columns[0].DisplayIndex it works fine! Any ideas? Ive got nothing :) Thankz
-
Yes but isnt it possible to access both like Columns[integer] and Columns[String]? Then i dont have to know the actual index for the column i seek. Thats the beauti :)
See, I know that Columns[string] works so without further evidence I am forced to assume that you are not using a valid string value. My post was suggesting that you look at the Name properties of all the columns to find your error. Apparently my short post was not enough to steer you in that direction.
-
See, I know that Columns[string] works so without further evidence I am forced to assume that you are not using a valid string value. My post was suggesting that you look at the Name properties of all the columns to find your error. Apparently my short post was not enough to steer you in that direction.