Controls in Listbox

Controls in Listbox

Postby Greg Gammon » Thu Jun 29, 2006 4:14 pm

Is it possible to use controls within listboxes? specifically I would like to use a checkbox for logical fields. I saw a Q&A on TWBrowse + Checkboxes, but alas I don't read Espanol.
Greg
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby James Bott » Thu Jun 29, 2006 5:19 pm

Greg,

You have to use a trick to make it appear like it is a control. Below is a copy of my notes on this.

James

----------------------------
Here is how to do a checkbox in a listbox:

You need to use two bimaps for the checkbox, one checked and one unchecked. Load the bitmaps:

hChecked:=loadbitmap( getresources(),"checked")
hUnchecked:= loadbitmap( getrources(),"unchecked")


Define the bitmaps conditionally in the listbox definition:

@0,0 listbox oLbx fields date, description, ;
if(empty(::oTask:completed),hChecked,hUnchecked)

Then you have to define an action when the column is clicked on:

oLbx:blClicked := {| nRow, nCol| ( if(oLbx:nAtCol(nCol)=3,;
toggleCheck(),),oLbx:drawSelect()) }

The above line checks for column 3. If that is the column, then the function toggleCheck() is called. ToggleCheck() toggles the variable and saves the record. Finally, you redraw the line using oLbx:drawSelect().

[Note: You may need to pass nRow and check to make sure it is greater than 15 to avoid triggering the checkbox when the user clicks on the header. See file:///c:\apps\todo\task.prg, method click() for an example.]
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Ehab Samir Aziz » Fri Jun 30, 2006 5:14 pm

Can I use combobox in a listbox ? I need to edit a record in listboxes using dbcombobox to enter fixed values via each field in the record .
Ehab Samir Aziz
 
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Postby Greg Gammon » Fri Jun 30, 2006 6:09 pm

James...thanks for the code...i'll give it a shot in the next week or so.
I can see need for combobox usage in a listbox as well....im thinking that is quite a bit more complicted?
Greg
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Postby James Bott » Fri Jun 30, 2006 6:12 pm

I have never used a combobox in a browse. Antonio mentioned in generic terms how to do it recently in another message thread. There may be something in the samples directory.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Fri Jun 30, 2006 6:53 pm

Have a look at how TWBrowse:EditCol() and TWBrowse:lEditCol() methods are implemented.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8600
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 109 guests