How to : Loading an combobox at runtime with items ?

Started by Stephane Fonteyne, September 24, 2013, 05:04:04 AM

Previous topic - Next topic

Stephane Fonteyne

Hi all,

Problem 1:
How can I loading a combobox with items at runtime. Can you explean with a short example and what FF function do I use?

I have an array of items : "appel", "peer", "citroen"

Problem 2
How Can I delete or add an new item in the combobox. Is that true first selected an item or search the specific item and then execute the operation "remove item", "add item", "search item"

Can you explean with a short example and what FF function do I use?
I know i can understand it in VB but not in FF3

Kind regards
Stephane
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Paul Squires

Quote from: Stephane Fonteyne on September 24, 2013, 05:04:04 AM
Hi all,

Problem 1:
How can I loading a combobox with items at runtime. Can you explean with a short example and what FF function do I use?

I have an array of items : "appel", "peer", "citroen"

FF_ComboBox_AddString HWND_FORM1_COMBO1, "appel"
FF_ComboBox_AddString HWND_FORM1_COMBO1, "peer"
FF_ComboBox_AddString HWND_FORM1_COMBO1, "citroen"

Quote
Problem 2
How Can I delete or add an new item in the combobox. Is that true first selected an item or search the specific item and then execute the operation "remove item", "add item", "search item"

You do not have to select an item in order to delete it. All you need to know is the index number (the position) of where the item in the combobox. The item list is zero based, so in your example above, the indexes would be "appel" = 0, "peer" = 1, "citroen" = 2

To delete "citroen":
FF_ComboBox_DeleteString HWND_FORM1_COMBO1, 2

When you add an item, the index/position where the item is added is returned from the function. Therefore, using the above example you could have coded it like this:
nIndex = FF_ComboBox_AddString( HWND_FORM1_COMBO1, "appel" )
nIndex = FF_ComboBox_AddString( HWND_FORM1_COMBO1, "peer")
nIndex = FF_ComboBox_AddString( HWND_FORM1_COMBO1, "citroen")

If you need to delete the currently selected item in the combobox then you could use code like the following:
nIndex = FF_ComboBox_GetCurSel( HWND_FORM1_COMBO1 )
FF_ComboBox_DeleteString HWND_FORM1_COMBO1, nIndex

If you need to search for a string and then delete it then you would use the nIndex value that a function like FF_ComboBox_FindString would return.

FF_ComboBox_AddString always adds a new string to the end of the combobox list.
Use FF_ComboBox_InsertString if you want to add a string somewhere in between.
Paul Squires
PlanetSquires Software

Stephane Fonteyne

Paul,
Can you place an example that demostrate all the functions from een ComboBox in FF3.

Operations:

- Add items, Remove items, Insert Items, Search Items

Thanks
Stephane
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Paul Squires

Did you not even read my post? Did I not use my grasp of English sufficiently enough to explain exactly what it is you are looking for? I told you how to Add, Remove, Insert and Search items. If you did actually read it, then obviously you did not understand, or can not understand, how extremely easy it is to use those functions on a ComboBox. Me writing yet another example will not make you understand it any better. I am lost with how to help you. Completely lost.



Paul Squires
PlanetSquires Software

Elias Montoya

Paul, i believe the problem is that stephane doesnt speak good english.

Stephane, Paul created functions with names like these: FF_Combobox_AddString. If you Dont Know what AddString is, just separate the words by the CAPS . For example AddString becomes Add String. This can help you translate names easier.

A translator might not tell will not tell What AddString means, but if you sepatate the words manually, a translator will come handy.

You ask for very specific help, i believe rather than keep asking for such a simplistic help direcly is a waste of time, put some effort on your side and learn the commands. You keep asking in many forums the same question, and you want th complete program ready, even i tried to help you with scrollbars.

In Firefly Press F8. Goto Combobox. Learn ecah command.

We are trying to teach you how to fish. Stop asking for the fish directly. :)


Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

Joerg B.

#5
Hello @All

I think that Stephane can make enough English to his demands.
And its formulations are almost always in the imperative.

Stephane want without own effort made solutions.

We know, learning a programming language does not work that way.

But I feel, why he does not often get more answers in the forums.

@ Stephane

I have nothing against you Stephane!

If a baby needs milk or porridge and needs to be fed then that's normal.
If an adult eats only milk or porridge and must always be fed, not more.

You should get away from convenience foods and learn to cook yourself.

// Sorry i know it is off-topic
Greeting from Germany

Joerg