About searches ComboBox

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

About searches ComboBox

Post by jparada »

Translated by Google,

I have several in the combobox that I need to search within the content in a dbf, apparently searching for "default" that performs the control is not sufficient to carry out what I need, another forum in a post related to exactly what I need refer to using the Windows API for it, I have no idea how to do this, any suggestions to make searches in the ComboBox control?

Thanks

Greetings
Javier

Spanish,

Tengo varios Combobox en los que necesito realizar búsquedas dentro del contenido en una dbf, al parecer la búsqueda por "default" que realiza el control, no es suficiente para lo que necesito realizar, en otro foro en un post relacionado a exactamente lo que necesito, hacen referencia a utilizar la API de Windows para realizarlo, no tengo idea de cómo hacerlo, alguna sugerencia para poder realizar las búsquedas en control Combobox?

Gracias

Saludos
Javier
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: About searches ComboBox

Post by Rathinagiri »

By searches, you mean, searching an item by typing the first few letters?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

Re: About searches ComboBox

Post by jparada »

Translated by Google,

Thanks for answering Rathinagiri, so this is what I need, go to the keyboard letters in an element that is positioned in the most similar and that the search is not lost on names separated by spaces.


Thanks
Greetings
User avatar
gfilatov
Posts: 1057
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: About searches ComboBox

Post by gfilatov »

jparada wrote: Thanks for answering Rathinagiri, so this is what I need, go to the keyboard letters in an element that is positioned in the most similar and that the search is not lost on names separated by spaces.
Kindly take a look for a working sample below:

Code: Select all

/*
* MiniGUI ComboBox Demo
*/

#include "minigui.ch"

Procedure Main
Local aItems := {}, i

	for i=1 to 2500
		aadd(aItems, "$" + ltrim(str(i)))
	next

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 200 ;
		TITLE 'ComboBox Demo' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'Test'
				MENUITEM 'Get Value for Combo_2' ACTION MsgInfo(Str(Form_1.Combo_2.Value))
				MENUITEM 'Set Value for Combo_2' ACTION Form_1.Text_2.Value := '1'
			END POPUP
		END MENU

		@ 10,160 COMBOBOX Combo_2 ;
			ITEMS aItems ;
			VALUE 1000

		@ 40,160 TEXTBOX Text_2 VALUE '1000' ;
			ON CHANGE Form_1.Combo_2.Value := ComboSearch(aItems, Form_1.Text_2.Value)

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return


Function ComboSearch( aArray, cValue )
Local nPos

	nPos := Ascan(aArray, {|e| SubStr(e, 2) = cValue})

Return nPos
I hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

Re: About searches ComboBox

Post by raumi75 »

You might also want to try the SORT Option. Ratinagiri gave me that tip and it worked for my problem.

viewtopic.php?f=14&t=186
jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

Re: About searches ComboBox

Post by jparada »

Translated by Google,

Thanks for answering, Grigory, the solution provided is not adequate for me, because I do not have referred to him TexBox add search functionality to the ComboBox.

Raumi, You can not use the Sort property, using the property ItemSource.

Also, I had not noticed, or at least not with that property to do so, it is not possible to type in the ComboBox, I have seen in some ComboBox lets you type text and display the list of items.

If this is not possible, then I think I am wrong in choosing the wrong control to do what I need and I would ask your opinion on this, I've also been thinking about doing so with a TextBox and probably could also implement the AutoFill I want, but could do this with a TextBox, if it is not possible in the ComboBox.

Finally, I would be able to implement the two functions: the power to enter text to search and can also auto.

Thanks

Greetings
Javier

Spanish,

Gracias por contestar, Grigory, la solución que proporcionas no es la adecuada para mi, ya que no tengo contemplado adicionar un TexBox para darle la funcionalidad de búsqueda al ComboBox.

Raumi, No se puede utilizar la propiedad Sort, si se utiliza la propiedad ItemSource.

Además, no me habia dado cuenta, o al menos no se conque propiedad hacerlo, que no es posible escribir en el ComboBox, he visto que en algunos ComboBox te permite teclear texto así como desplegar la lista de elementos.

Si esto no es posible, entonces me parece que me estoy equivocando al elegir el control incorrecto para realizar lo que necesito y quisiera pedir su opinión al respecto, también he estado pensando en la posibilidad de hacerlo con un TextBox y así probablemente también podría implementar el Autocompletado que quiero, pero como podría hacer esto con un TextBox, si no es posible con el ComboBox.

En fin, quisiera poder implementar las dos funcionalidades: el poder teclear el texto a buscar y que también se pueda autocompletar.

Gracias

Saludos
Javier
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: About searches ComboBox

Post by esgici »

Hola Javier
jparada wrote: ..., it is not possible to type in the ComboBox, I have seen in some ComboBox lets you type text and display the list of items. If this is not possible ...
Typing in or editing displayed value in COMBOBOX is possible. The keyword is DISPLAYEDIT. Please look at C:\hmg\SAMPLES\COMBO_4\demo.prg or my humble example Dynamic Combox
I think I am wrong in choosing the wrong control to do what I need and I would ask your opinion on this, I've also been thinking about doing so with a TextBox
My humble opinion is : the COMBOBOX couldn't be best for all searching purpose and I guess that you need a "Quick Search" method.

Please look at attached example.

I hope that help you.

Regards

--

Esgici
Attachments
QuickSearch.zip
(29.44 KiB) Downloaded 965 times
Viva INTERNATIONAL HMG :D
jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

Re: About searches ComboBox

Post by jparada »

Translated by Google,

Thanks for answering Esgici,

Your proposal is similar to that of Grigory, I think that unfortunately is not the kind of solution that I need, the subject is in a form that I need to use two for a ComboBox ComboBox for other cities and states, so that aesthetically speaking not I seem feasible earlier proposals, at least that's my opinion, however, that you think of another way to resolve this approach, because analyzing from another perspective, too many cities and if I can not do a good approach to show the interface properly, although technically achieve what I need (search), will not help for the user.

I have thought about changing the ComboBox for a TextBox, but how can "link" to the dbf to do Search and foremost I would like "crazy" to have the idea of the auto, I've seen in some programs, plus I also want to contemplate the possibility that if the item is not wanted there, give option to register from the current form form and not go to cities for example. (gosh, all this I have implemented in clipper), and suddenly in this Windows environment, I do some complicated and others an advantage.

Thank you very much

Best regards
Javier

Spanish,

Gracias por contestar Esgici,

Tu propuesta es similar a la de Grigory, desafortunadamente creo que no es el tipo de solución que yo necesito, el tema es que en un form yo necesito usar dos ComboBox uno para ciudades y otro ComboBox para estados, por eso, que estéticamente hablando no me parecen viables las propuestas anteriores, al menos ese es mi opinión, ahora bien, que opinan ustedes, de que otra manera pudiera resolver ese planteamiento, porque analizando desde otro punto de vista, son demasiados ciudades y si yo no logro hacer un buen planteamiento para mostrar la interface adecuada, aunque técnicamente logre lo que necesito (búsqueda), no será de ayuda para el usuario.

He pensado en la posibilidad de cambiar el ComboBox por un TextBox, pero cómo se puede "enlazar" a la Dbf para que haga la búsqueda y sobre todo me gustaría como "loco" poder tener la idea del autocompletar, que he visto en algunos programas, además también quiero contemplar la posibilidad de que si el elemento buscado no existe, dar opción a dar de alta desde el actual formulario y no ir al formulario ciudades por ejemplo. (caramba, todo esto lo tengo implementado en Clipper), y de repente en este entorno Windows se me hacen algunas cosas complicadas y otras tantas una ventaja.

Muchas Gracias

Saludos cordiales
Javier
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: About searches ComboBox

Post by sudip »

Hello Javier,

Nice to meet you :)

May be I can't understand your requirement, but I suppose you want Combo Box with text typing facility :)
It's the default type of combobox in VFP.
I am asking this because to solve any problem, we must understand it very clearly. :)
(gosh, all this I have implemented in clipper), and suddenly in this Windows environment, I do some complicated and others an advantage.
Friend, here we all faced (and facing) the same problem. :) I faced this problem 3 times. When I transferred from Clipper to VFP and when Clipper to xHarobur+gtvww (very little problem) and when I started HMG :)

So, IMHO please write the structures of tables first and specify what is your Primary key and Foreign Key (I know dbf doesn't have those keys!!!). Then write what you want to do. And if possible, specify what will be your proposed solution. I think this will help to solve the problem. :)

With best regards.

Sudip
With best regards,
Sudip
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: About searches ComboBox

Post by sudip »

Hi Esgici,
Esgici wrote:My humble opinion is : the COMBOBOX couldn't be best for all searching purpose and I guess that you need a "Quick Search" method.
I agree. I ran your QuickSearch demo. Excellent! I also ran your Dynamic Combobox demo. Both are very good!!!
I like your way of programming. Because it "works", and I can "understand" it. :)

I wish, if I can write this type of codes - simple and effective ;)

With best regards.

Sudip
With best regards,
Sudip
Post Reply