|
-
Oct 1st, 2021, 10:51 PM
#1
Re: Strange DGV Behavior
Why are you using that code to replace an existing column in the first place? Why not just add the combo box column in the designer? I'm guessing that you are letting the grid create the columns when you bind data and then replacing one of the columns it creates. Don't do that. Create the column you want in the first place. If you set the DataPropertyName of the column then your data source will be correctly bound to it, even if AutoGenerateColumns is True. There's a demo in my CodeBank submission on the subject.
-
Oct 9th, 2021, 05:40 PM
#2
Re: Strange DGV Behavior
 Originally Posted by jmcilhinney
Why are you using that code to replace an existing column in the first place? Why not just add the combo box column in the designer? I'm guessing that you are letting the grid create the columns when you bind data and then replacing one of the columns it creates. Don't do that. Create the column you want in the first place. If you set the DataPropertyName of the column then your data source will be correctly bound to it, even if AutoGenerateColumns is True. There's a demo in my CodeBank submission on the subject.
I tried your code in the CodeBank and it's not working.
Actually, it is working fine. In fact, it's an excellent example and very well written, but I felt it would be bad form not to start out with something totally useless, and "it's not working" is about as useless as things get.
However, what I DID see from that example is that the behavior I am seeing is happening in my test project when I run your code. I expect that what is going on is that, when you select an item in the drop down, then go to the next drop down, the first thing that happens is that focus switches from the first cell to the second cell. So, the first click is changing the focus, and only once the second cell has focus does the drop down actually drop down.
Now that I have more experience with where I am going with my design, this is more acceptable. It's not ideal, but in the form I am working on, the user will only very rarely use the drop down at all. Most of the time, they'll be setting a value and auto-filling all records. I might enhance that a bit by auto-filling just some selected rows.
So, the next piece I have to get back to is figuring out why those fool columns are visible even when visible is set to false.
My usual boring signature: Nothing
 
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
|