combox and databinding

E

Eva

Does anyone know how i can connect my combobox to my
acces DB? i have tried setting the datasource to a
dataset but i cannot seem to locate the item property
under the DataBindings list.
I ended up binding the text property, but the combobox
remains unpopulated. Is there anyway i can refresh the
data stored in here every time i click on the tab control
on my form??


thx.
 
C

Cor

Hi Eva

Did you set the displaymember too?
Does anyone know how i can connect my combobox to my
acces DB? i have tried setting the datasource to a
dataset but i cannot seem to locate the item property
under the DataBindings list.

Cor
 
A

Armin Zingler

Eva said:
Does anyone know how i can connect my combobox to my
acces DB? i have tried setting the datasource to a
dataset but i cannot seem to locate the item property
under the DataBindings list.
I ended up binding the text property, but the combobox
remains unpopulated. Is there anyway i can refresh the
data stored in here every time i click on the tab control
on my form??

As this question is not VB.NET specific, please turn to
microsoft.public.dotnet.framework.windowsforms.databinding
 
E

Eva

Hi Cor,

yep i set the datamember to the column i needed.
I have finnaly got the details to appear but, i keep
getting the following message when the form first opens:

An unhandled exception of
type 'System.Data.ConstraintException' occurred in
system.data.dll

All i did was to write distinct in front of the query to
eliminate duplicate rows. my query is:

SELECT Distinct [Caravan Model]
FROM [Caravan details]


It seems to work when i put:
SELECT [Caravan Model], [Caravan Inv No]
FROM [Caravan details]

Caravan Inv No is the Primary key.
Any idea what i should do?


Additional information: Failed to enable constraints. One
or more rows contain values violating non-null, unique,
or foreign-key constraints.
 
C

Cor

Hi Eva,
I don't know now, one of the not nice thing with databinding a combobox is
that it start direct with changing the selected index when the program
initiate.

From that becomes a lot of strange errors when you uses that. (It is the
event what is automaticly made if you click in the designer on the
combobox).

Some ideas are to delete the handler and add it by code in the load event of
the form, but you can first just set a switch for that.

I don't know if that is the problem, but most probably it is.

Cor
 
M

Mike Caputo

Armin Zingler said:
As this question is not VB.NET specific, please turn to
microsoft.public.dotnet.framework.windowsforms.databinding

Oh come on, man... this is exactly the kind of thing everyone was just
talking about in the thread regarding "netiquette". Take a break... how can
it hurt to ask this question in here?

Mike
 
M

Mike Caputo

I think Cor is probably right that the problem is being caused by the event
handler being triggered. What I do to avoid this is set up a global Boolean
flag called FillActive. I put a check on this flag in any event handlers of
controls that can be databound. For example:

Private Sub ComboBox1_Click(sender as Object, e as EventArgs) _
Handles ComboBox1.Click
If FillActive Then
<event code here>
End If
End Sub

Then I just set the flag to false whenever I'm about to fill the control.
It's kind of a pain in the ass, but it means you can standardize procedures
for filling List controls without having to do RemoveHandler and AddHandler.
Hope this helps.

Mike
 
C

Cor

Hi Mike,
Are you native English?
I suddenly saw a word in the sentence Armin uses that can maybe give all
those sometimes for Armin agresive reactions when Armin write this, while he
probably does not know why it is.

Normaly I would ask this to Fergus, but I don't see him.

In my language and I know that it is in the German language is too a quiet
simular word, "wend" that means, for information you can "turn to" that
adres. Using "wend" is polite in itself. (In my language we use it for this
and for ships).
I think I would in this case maybe use "apply for" because "turn to" sounds
something commanding for me.

But I am not a native English speaker so maybe it is something that is only
in my ears?


Cor
 
I

IbrahimMalluf

Show us your code that populates the combo

Ibrahim (looks like a vb question to me) Malluf
 
M

Mike Caputo

Hi Mike,
Are you native English?
Yes

I suddenly saw a word in the sentence Armin uses that can maybe give all
those sometimes for Armin agresive reactions when Armin write this, while he
probably does not know why it is.

Normaly I would ask this to Fergus, but I don't see him.

In my language and I know that it is in the German language is too a quiet
simular word, "wend" that means, for information you can "turn to" that
adres. Using "wend" is polite in itself. (In my language we use it for this
and for ships).
I think I would in this case maybe use "apply for" because "turn to" sounds
something commanding for me.

But I am not a native English speaker so maybe it is something that is only
in my ears?


Cor

I understand the point you're trying to make, but this is not the problem.
"Turn to" is not impolite (it's not what I would have said as a native
speaker, but it works fine here). "Apply for" would not be right. You
could say "check out" or just "see". What I objected to was Armin being a
little bit overzealous about exactly classifying the question, which as far
as I'm concerned falls well within the bounds of a general VB discussion.
The tone of the phrase "As this question is not VB.NET specific" is rather
peremptory (unabweisbar) and, in my opinion, not at all appropriate. There
is absolutely nothing to be gained by brushing people off (abblitzen lassen)
in the way Armin was clearly trying to do.

Mike
 
C

Cor

Hi Mike,
I am sure after a lot of discussions about this, that there is a helpfull
meaning in it from Armin. Sometimes it is on the wrong place on the wrong
time, we all do that sometimes.

And Thanks
:)
Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top