combobox behaviour

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Hi,
I create a combobox in the new event of a form. Fill datasource with dataset
and so on.
Works in so far that the items (combo.items.count) only show after the load
event. I found a workaround by setting the visible prop to true and
immediatly to false again (in the new sub).
Why is this happening and is there a better solution for it?
Thanx
FRank
 
Hi Frank,

The combobox is a very nice control, however it has a lot of let's call it
unexpected behaviours.

To use a combobox with a datasource, the easiest way for that is to make a
global Boolean that you set to true in the end of the load event. In your
selectedindexchange event you can than set
\\\
If switch or whatever name you use is true then
///
When you want to show a empty textbox you have to set twice (you read that
well) also the selected index to -1 in that load event.

I hope this helps?

Cor
 
Thanks for your reply Cor, but I don't get it.

You write: if switch is true then...

Then what?

And what load event do you mean, the form load?

Thanks
Frank
 
Hi Frank,

Yes the form load,

The combobox is mostly processed from the index change event.

In that you can make something as
Private event index...........................
If AllLoadedSw then

' do your stuff

End if
End sub
 
When you say the new event, I suppost you mean the Sub New ?

Declare this a a class level object and instaniate it in On_Load
 
Cor,
I don't need an event. But I found something about cb's on the inet, thats
probably what u are refering to. But I am not sure that's my problem.
The cb is filled properly, but before the load event the items.count =0, in
the formloadevent it is x. So if I choose an item before the formload the
shown cbitem is wrong. If I choose an item in the formload the selecteditem
is set correctly.
So I moved the filling of the cb to the formload.
Still a strange behaviour, is it considered a bug by MS?
Frank
 
Still a strange behaviour, is it considered a bug by MS?

I wrote it as this Frank.
unexpected behaviours

That means that when it it loading a datasource the most strange things can
happen. It fires events suddenly, the index change fires two times by
instance. That is true that it change when it is loading a datasource,
however you would expect that that would be suppressed, but it is not.

Another very known thing is that when you want to set the index initially
to -1 (empty) you have to do that twice.

Cor
 
Back
Top