|
-
Nov 16th, 2009, 12:20 PM
#1
Thread Starter
Lively Member
[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!
-
Nov 16th, 2009, 04:09 PM
#2
Thread Starter
Lively Member
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.
-
Nov 16th, 2009, 10:02 PM
#3
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.
-
Nov 17th, 2009, 11:47 AM
#4
Thread Starter
Lively Member
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.
-
Nov 17th, 2009, 06:14 PM
#5
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.
-
Nov 18th, 2009, 08:33 AM
#6
Thread Starter
Lively Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|