|
-
May 14th, 2010, 09:12 PM
#1
Thread Starter
Member
[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.
-
May 14th, 2010, 10:40 PM
#2
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.
-
May 15th, 2010, 12:36 AM
#3
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|