Results 1 to 17 of 17

Thread: [RESOLVED] Strange DGV Behavior

Hybrid View

  1. #1
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  2. #2

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Strange DGV Behavior

    Quote Originally Posted by jmcilhinney View Post
    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
  •  



Click Here to Expand Forum to Full Width