Page 1 of 1

ComboCheckList

Posted: Mon Feb 03, 2014 5:17 am
by zolysoftsolutions
Hello my friends,

I wish to have a possibility to check multiple items from a combobox.

By example: I have in the combo items 7 colours, but I want to mark in some way 3 of them and the value of the combo to be retourned as an array.

I checked the samples, I searched the forum. Don't found something like this.

Can somebody give me a tip?

I can solve with a textbox, a commandbutton and a visible/invisible list, but I feel that exist something more simple here. :)

I am using HMG 3.1.1

Best regards,
Zoli B.

Re: ComboCheckList

Posted: Mon Feb 03, 2014 6:02 am
by Rathinagiri
Mulitselect is available only in ListBox and Grid controls. I don't think it is possible in a combobox as of now.

Re: ComboCheckList

Posted: Mon Feb 03, 2014 6:26 am
by zolysoftsolutions
Thank you for information Rathinagiri.

So I have to write a function with the 3 controls combination: textbox to display the current value, a commandbutton for make the list visible/invisible, and a list with the items and with multiselect.

something like:

xchoices:={'Red','White','Blue','Black','Yellow'}
xresult:={}
xresult:=combocheck(25,40,xchoices)

;) Happy HMG-ing...

Best regards,
Zoli B.

Re: ComboCheckList

Posted: Mon Feb 03, 2014 6:19 pm
by Javier Tovar
Hi zolysoftsolutions

Code: Select all

/*
* HMG Hello World Demo
* (c) 2002-2004 Roberto Lopez <mail.box.hmg@gmail.com>
*/

#include "hmg.ch"

Function Main
PUBLIC aItems := { 'Hola','Como','Estas','En','Este','Dia' }
	DEFINE WINDOW Win1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'DRAGITEMS LISTBOX' ;
		MAIN 

		DEFINE LISTBOX LIST1
			ROW		10
			COL		10
			WIDTH		100
			HEIGHT		110
			ITEMS aItems
			MULTISELECT .T.
			ONLOSTFOCUS VerSeleccion()
		END LISTBOX
		
		DEFINE TEXTBOX TEXT_1
			ROW		10
			COL		200
			WIDTH		100
			HEIGHT		20
		END TEXTBOX
		

	END WINDOW

	Win1.Center

	ACTIVATE WINDOW Win1 

Return

PROCEDURE VerSeleccion()
LOCAL aValores := Win1.List1.VALUE

FOR n:= 1 TO Len(aValores)
	MsgBox(STR(aValores[n]) + " " +aItems[aValores[n]])
NEXT n

RETURN NIL
Regards

Re: ComboCheckList

Posted: Tue Feb 04, 2014 6:04 am
by zolysoftsolutions
Hi,

As a beginner I solved the problem in folowing way:

The combocheck function will create the possibility to check from the list multiple items, but at overall look like a combo with multiple selection.
Not all the time we have place to keep the listbox visible.

Is not very proffesionist, but it works, and for me is very usefoul. I shared it, maybe is usefoul also for others.

First parameter is windowname.
Second is a name allocated by user. The checked items will be stored
as a string in the textbox created by the function. By example, in this case the textbox
name is "ccnametext". The main.ccnametext.value is really the result of the function.

Third parameter is the row where the texbox is placed

Fourth parameter is the column where the texbox is placed

Fifth is the leght of the textbox. The overall lenght of the combocheck will be this value+24

Sixth parameter is the name of the array containing the elements of the list

The example attached.

Best regards,
Zoli B.

Re: ComboCheckList

Posted: Tue Feb 04, 2014 12:09 pm
by danielmaximiliano
Thank“s Zoli ...

New User.Component

Re: ComboCheckList

Posted: Tue Feb 04, 2014 3:33 pm
by danielmaximiliano
Hola Claudio:

es posible esto ?
una forma de habilitar multiple seleccion de un ComboBox

is this possible?
a way to enable multiple selection in a ComboBox

http://www.codeproject.com/Articles/210 ... -Class-and

Re: ComboCheckList

Posted: Tue Feb 04, 2014 5:01 pm
by zolysoftsolutions
Updated. No problems with controls overlapping.

Code attached.

When the items are selected, you have to press a simple Enter, or to click inside the textbox above.

Best regards,
Zoli B.

Re: ComboCheckList

Posted: Tue Feb 04, 2014 5:13 pm
by Javier Tovar
Hola zolysoftsolutions,

Ahora si que me sorprendiste :o
Combinando varios controles podemos llegar a "otro" que llena nuestras necesidades! Excelente!

Felicidades.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Hello zolysoftsolutions,

Now if that surprised me :o
Combining multiple controls can come to "other" that fills our needs! Excellent!

Congratulations.

Re: ComboCheckList

Posted: Thu Feb 06, 2014 10:59 pm
by srvet_claudio
danielmaximiliano wrote:Hola Claudio:

es posible esto ?
una forma de habilitar multiple seleccion de un ComboBox

is this possible?
a way to enable multiple selection in a ComboBox

http://www.codeproject.com/Articles/210 ... -Class-and
Hola Daniel,
voy a estudiar el asunto.