Results 1 to 3 of 3

Thread: [RESOLVED] Combobox and database messes up form

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2008
    Posts
    43

    Resolved [RESOLVED] Combobox and database messes up form

    Hi.
    In my Thesaurus application, I use a combobox as a lookup for keywords. On the bottom of the form I have a datagridview that displays the synonyms for the currently selected keyword.

    The problem I'm having is that whenever I have selected a keyword that has synonyms, or in other words, whenever a keyword is selected that populates the datagridview, and at the same time I try to close the form or remove the keyword my form gets messed up.

    I can't exit the application by pressing the X button, I can't remove the keyword, I can't give focus to other controls and if I try to open the dropdownlist in the combobox, it just briefly flashes before it is closed.
    Again, this only happens to words with synonyms and it only happens after I've either tried to close the form or remove the keyword from the database.

    What could be causing it?

    Edit:
    About the remove problem.
    The two tables are related by "KeywordID", I just set it to cascade on delete and update. The problem still persists though. I can now delete the first item in the combobox but only if I haven't given it focus yet. As soon as I give the combobox focus, I can't delete entries or exit the form while having selected words with synonyms.
    Last edited by twister06; May 14th, 2010 at 09:29 PM.

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

    Re: Combobox and database messes up form

    My guess is that those actions cause an event to be raised (maybe SelectedIndexChanged on the ComboBox or maybe something else) and in the event handler you are making an invalid assumption, e.g. that the are rows in the grid. I would suggest putting breakpoints on all your event handlers and see if that's the case. Once you know what the invalid assumption is you can add an If statement to test for that condition.
    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

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2008
    Posts
    43

    Re: Combobox and database messes up form

    I found the error.
    I had set both the displaymember and the valuemember to Keyword because I was trying something out earlier and I forgot to reset it. Changed ValueMember to KeywordID and it straightened it up.

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