[RESOLVED] Current cell cannot be set to an invisible cell
Yet another invisible cell problem.
So I've got 2 unbound datagridviews, and am providing a push/pull interface where the user can move records from one to the other.
Grid A is read-only and the selectionmode is set to FullRowSelect. Grid B has a read-only DataGridViewTextBoxCell, an editable DataGridViewComboBoxCell, and an editable DataGridViewComboBoxCell.
Because the grids have different columns, but represent the same records, my notion was to create the datagridviews with the same column structure but hiding certain columns, and then just move the DataGridViewRows back and forth between the two, which seams to work.
The problem is that if I go into column 2 or 3 in grid B, I get "Current cell cannot be set to an invisible cell".
I can select cells in column A and I'm fine. It should be noted that on grid B the hidden columns are 4-7.
I know there's a problem when the CurrentCell attribute is set to a hidden cell, but I'm clicking visible cells. I inserted a breakpoint on the CellClick event of the DGV, and again for column 1 that works fine, but on columns 2 and 3 it looks like the error is occuring before the event even gets fired.
What am I missing? Is something in the background setting CurrentCell to one of the hidden cells before firing the event?
Thanks in advance!
Re: Current cell cannot be set to an invisible cell
The plot thickens.
So that I could keep developing I made all the columns visable.
Low and behold, I'm STILL GETTING THE ERROR!
Interestingly I only get it on editable columns, I can click around the read-only ones all day.
Any help would be greatly appreciated.
Re: Current cell cannot be set to an invisible cell
I very much doubt that this is due to your clicking a cell. I would expect that you have some code that, when a cell is clicked, sets the CurrentCell of one of the grids. Have you looked at the call stack of the exception to see exactly where the exception is being thrown. The IDE gives you information when an error occurs so that you can diagnose it.
Re: [RESOLVED] Current cell cannot be set to an invisible cell
Figured out what was going on.
Because I was moving the rows from one grid to the other, it was erroring because those cells were invisible on grid A.
The solution was to create a new row object and copy the values over.
Re: [RESOLVED] Current cell cannot be set to an invisible cell
Hmmm... seems so obvious once you know but that didn't occur to me either.
Re: [RESOLVED] Current cell cannot be set to an invisible cell
I know, it was a smack-yourself-in-the-forehead kind of moment.
Working beautifully now, though. I'm still surprised they haven't added the push-pull lists to the toolbox.