Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid - Multiple Selects
Message
From
11/05/1998 13:47:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00098532
Message ID:
00098537
Views:
34
>I am interested in making a grid act like a list box control. I want multiple fields in the grid as you can do in the list box, but I want the look and feel of the grid. Has anyone succedded in making a grid control like a list box where you select multiple rows and the color of the selected row(s) changes? I know with the grid's dynamic color propertly I can change the row color. How would I capture a mouse click and know which row I am on to change to color?
Hello,
This is not finished yet but you could use it as a starter :
clear all
cSQL = "* from employee order by last_name"  && Passed as a param

cSQL = stuff(cSQL,atc(" from",cSQL),;
	0,",.f. as lSelected,.f. as lLastSelected")
select &cSQL into cursor myCursor 
use dbf("myCursor") in 0 again alias tcSelector
use in "mycursor"
select tcSelector
oSelectorForm = createobject("Form")
oSelectorForm.height = 400
oSelectorForm.width = 600
oSelectorForm.visible = .t.
oSelectorForm.closable = .f.
oSelectorForm.addobject("mygrid","grid")
oSelectorForm.addobject("myQuit1","myQuit")
with oSelectorForm.mygrid
	.recordmark = .f.
	.deletemark = .f.
    .recordsourcetype = 1
    .recordsource = "tcSelector"
    .columncount=fcount("tcSelector")-2
    for ix=1 to .columncount
     .columns(ix).removeobject("Text1")
     .columns(ix).addobject("myTextBox","myTxtBox")
     .columns(ix).currentcontrol = "myTextBox"
    endfor
    nBackColor = .columns(1).myTextBox.SelectedBackColor
    nForeColor = .columns(1).myTextBox.SelectedForeColor
    .setall("DynamicBackColor","iif(lSelected,"+str(nBackColor)+",rgb(255,255,255))","column")
    .setall("DynamicForeColor","iif(lSelected,"+str(nForeColor)+",rgb(0,0,0))","column")
    .left = 1
    .top = oSelectorForm.myQuit1.top + oSelectorForm.myQuit1.height + 2
    .width = .parent.width - 2
    .height = .parent.height - .top - 2
    .visible = .t.
endwith
oSelectorForm.myQuit1.visible = .t.
oSelectorForm.show
read events

define class myquit as commandbutton
left=1
top=1
Caption="Close"
procedure click
	clear events
endproc
enddefine

define class myTxtBox as TextBox
BorderStyle = 0
procedure gotfocus
	this.backcolor = this.SelectedBackColor
	this.forecolor = this.SelectedForeColor
endproc
procedure lostfocus
	this.backcolor = rgb(255,255,255)
	this.forecolor = rgb(0,0,0)
endproc

procedure mousedown
lparameters nButton, nShift, nXCoord, nYCoord
thisform.lockscreen = .t.
if nButton = 1
	nodefault
	do case
		case nShift = 1 
		case nShift = 2
		otherwise
			nCurrec = recno()
			replace all lSelected with .f., lLastSelected with .f.
			go nCurrec
			replace lSelected with .t., lLastSelected with .t.
	endcase
endif	
thisform.lockscreen = .f.
endproc
enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform