Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox Explodes

Status
Not open for further replies.

rhnewfie

Programmer
Jun 14, 2001
267
CA
I put a combobox on my form, set the datasource to a datatable, set the value and display members and now when I click on the combo the app crashes.

Any ideas?

Thanks!
 
Since many programmers do that successfully, I would guess that you are doing something wrong. Unless you provide something more substantial, only wild guesses can be made as to what the solution may be.

[vampire][bat]
 
I agree... but I have done nothing more that I have said, it is wierd!


I simply dragged the control to the form, renamed it, and set the above - then boom when I touch it when the app is running.
 
I'm not sure the post by earthandfire was completely appropriate, however I have heard of this problem. Make sure that you have set the SelectedValue Property to the field in the table that it will be writing to.
 
Hmmm, not sure what you mean.

I am doing the following:

cboAccessLevel.DataSource = dt_AccessLevels
cboAccessLevel.ValueMember = "AccessLevelID"
cboAccessLevel.DisplayMember = "AccessLevel
 
It may be different if you are creating the control on the fly or using a different type of db connection, but you can set that in the Property pane in the main development window under DataBindings. You might be able to use something like:

cboAccessLevel.SelectedValue = Me.DataSetName.TableName.ColumnName

Like I said, it would depend on how you are connecting to the database.
 
artyk, are you saying that asking for a more detailed explanation and possibly some code is inappropriate? If so, please explain how and why.

[vampire][bat]
 
I am setting up the datasource and members from a datatable that I generate on the fly.
 
artyk, are you saying that asking for a more detailed explanation and possibly some code is inappropriate? If so, please explain how and why.

No I am saying the way you said it might not have been very professional. Obviously detailed information is key, but saying "Since many programmers do that successfully, I would guess that you are doing something wrong." seems a little harsh. We are trying to help people, not make them feel stupid for needing help.

rhnewfie,
I think I saw something about that recently in this forum. Try a search for "bound controls locking up" or something similar and I will see if I can track that thread down.
 
No I am saying the way you said it might not have been very professional. Obviously detailed information is key, but saying "Since many programmers do that successfully, I would guess that you are doing something wrong." seems a little harsh. We are trying to help people, not make them feel stupid for needing help.

I think earthandfire is a very respected member of this forum who has helped many people here before, hence the many stars he has. And I don't think he was harsh. This is a programmers forum and programmers use code. if you have a problem then it will probably be in your code so posting that code is vital to getting a swift and correct answer.



Christiaan Baes
Belgium

"My old site" - Me
 
artyk, to be honest, I think that I have helped far more people than you on both this forum and your other forum (Access Reports) - and had done so at an equivalent period in my membership. I really can not be bothered to fight with you. rhnewfie - to whom the original comment that so offended your sensibilities was addressed treated my post in the way in which it was intended. I was going to post a suggestion - but since you now feel you own this thread (and this forum???)- all yours artyk.

[vampire][bat]
 
earthandfire, I'm not trying to fight with you. I agree you are very helpful and a respected member of this forum as chrissie1 said. I won't argue with that. I also think detailed explanations (and code) are requisite, as you said. On the other hand I can identify with the position that rhnewfie is in. I have been in the same position when I haven't posted as much detail as was needed. I never said you were way out of line, just maybe not totally in line. If you are going to take that out on rhnewfie by withholding helpful info, that's on your conscience. As far as me "owning this thread": when did it become wrong to post? Owning this forum? Huh?!?
 
My suggestion - nothing too clever or outlandish.

I have absolutely no idea what the problem is or how to solve it. I have successfully used databound comboboxes on many occasions - therefore, I think the use of judiciously placed error handlers and possibly the subsequent posting of the errors reported (including the location of the error handler(s)) would be beneficial.

[vampire][bat]
 
Well

Whenever I click on the combobox I get

An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an object.

If I put a stop statement in the click event then I cannot even bring up the form.
 
Ok, you say you have some code in the combobox's Click event handler. Could you post that code?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
There is actually no code in the click event handler, I just tried to put a stop statement in there.
 
Does the database that you are using contain DBNULL in the column you are ref with the combo?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top