954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Cannot find column name.

So i have a datagrid and I have a databindingsource control for my text file. Works like a bomb, but then i added a toolstripmenu so that i can right click on the datagrid, a menu pops up and i can delete the row of data from the text file through the datagrid. I already have that design and must still code it, but i know how it works.

My problem is, my program cannot find the one and only column in the datagrid.

i make use of the following code:

string Delete = SWVerGrid.Rows[SWVerGrid.CurrentCell.RowIndex].Cells["Version"].Value.ToString();
MessageBox.Show(Delete);

I went to the form, looked at the column properties, its clear that "Version" is my column name, i played around with it some more, then every time at runtime, another "Version" column is created for some weird reason...but its not doing that any more. I don't know what i did to fix it. lol.

The error that i receive is: Column named Version cannot be found Parameter name: columnName

Anyone else experience this? untitled.jpguntitled1.jpg

Attachments untitled.jpg 30.43KB untitled1.jpg 25.87KB
Cameronsmith63
Light Poster
37 posts since May 2010
Reputation Points: 19
Solved Threads: 2
 

Is the "HeaderText" actually the column name?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

yip

Cameronsmith63
Light Poster
37 posts since May 2010
Reputation Points: 19
Solved Threads: 2
 

[Another test]
If you iterate through the columns numerically having the code write the column name to the debug window, do you see "Version" as a column name?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

there is only one column, the Version column. Another strange thing about this form is, if you look at that first pic, just above the datagrid, there is an outlining of the datagrid as well...i dont know why the gray lining is there when the actual datagrid is positioned properly.

Cameronsmith63
Light Poster
37 posts since May 2010
Reputation Points: 19
Solved Threads: 2
 

I understand there is one column, but something is going on that we both don't yet see.
All I really wanted was for you to make the code TELL you the name of the first column or any other columns it might see.
If it comes back null, that's a starting point.

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

i got it working now thanks. i used this:

string Delete2 = SWVerGrid.CurrentRow.DataBoundItem.ToString();
Cameronsmith63
Light Poster
37 posts since May 2010
Reputation Points: 19
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You