Page 1 of 1
Listbox Freeze column and goto a column ( ADO )
Posted: Fri Dec 14, 2007 6:55 pm
by Rick Lipkin
To All
I am using ADO to connect to MS SQL tables and have been using the standard FW listbox .. Twbrowse and have had no problems ..
I have one routine that needs to be able to 'freeze' the left column at column 5 and also need to be able to move the horozontal cursor to a specific column... say 10
I have been using Hernan's Twbrowse in my ADS version and it works quite will .. however, it has problems with ADO recordsets plus I have to link in ace32.dll .. which is not desirable for this applications.
I need to be able to do something like this .. oBrow:nFreeze := 5
and ON INIT oBrow:gotocol(10)
Does TxBrowse support non-aliased recordsets ?? and if so .. is it possible to freeze columns as well as move the cursor to a specific column ??
Many Thanks
Rick Lipkin
SC Dept of Health, USA
Posted: Fri Dec 14, 2007 7:32 pm
by Rick Lipkin
To All
I figured out how to edit Hernan's Twbrowse 'wbrowse.prg' and delete all the references to the different rdd's and left the standard FW behavior ..
But it would be nice to know if there is another listbox class that would be able to freeze and goto a specific column.
Rick Lipkin
Posted: Fri Dec 14, 2007 9:18 pm
by Armando
Rick:
Excuse me:
I am using ADO to connect to MS SQL tables and have been using the standard FW listbox .. Twbrowse and have had no problems ..
Would you send to me a small sample using ADO & FW listbox ?
My adreess
soisa2002 dot @ prodigy dot net dot mx
Kind regards
[/code]
Posted: Fri Dec 14, 2007 11:21 pm
by Rick Lipkin
Armondo
Here is a simple listbox look up program I use ..
xPROVIDER := "SQLOLEDB"
xSOURCE := "YOURSERVER"
xCATALOG := "DATABASENAME"
xUSERID := "SQLUSER"
xPASSWORD := "PASSWORD"
//-- grpslct.prg
//
//
STATIC oDLG,oLBX
#INCLUDE "FIVEWIN.CH"
//----------------------
Func GRPGET( cNAME, cMODE, oOBJ, oRs, cTABLE )
LOCAL oBTN1, oBTN2, oRs2,oErr, cSQL, cTITLE
IF cNAME = "ALL"
RETURN(.T.)
ENDIF
IF EMPTY( oOBJ )
oOBJ = " "
ENDIF
IF EMPTY( cTABLE )
cTABLE := "BOGUS"
ENDIF
IF cMODE = "E"
DO CASE
CASE cTABLE = "EMPLOYEE"
IF SUBSTR(cNAME,1,2 ) = SUBSTR(oRs:Fields("GROUP1"):Value,1,2) .and.;
oRs:Fields("GROUP1"):Value <> SPACE(2)
RETURN(.T.)
ENDIF
ENDCASE
ENDIF
IF EMPTY( cNAME )
cNAME := "BOGUS"
ENDIF
cNAME := UPPER(ALLTRIM(cNAME))
oRs2 := TOleAuto():New( "ADODB.Recordset" )
oRs2:CursorType := 1 // opendkeyset
oRs2:CursorLocation := 3 // local cache
oRs2:LockType := 3 // lockoportunistic
IF xADMIN = 'Y'
cSQL := "SELECT * FROM GROUPS order by progid,code"
cTITLE := "GROUP Select for ALL"
ELSE
cSQL := "SELECT * from GROUPS where progid = '"+xPROGID+"' order by code"
cTITLE := "GROUP Select for Progid "+xPROGID
ENDIF
TRY
oRS2:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oErr
MsgInfo( "Error in Opening GROUPS table" )
RETURN(.F.)
END TRY
IF EMPTY( cNAME ) .or. cNAME = " "
cNAME := "BOGUS"
ENDIF
cNAME := UPPER(ALLTRIM(cNAME))
oRs2:Find( "code like '"+cNAME+"%'" )
IF oRs2:eof
oRs2:MoveFirst()
ENDIF
DEFINE DIALOG oDlg RESOURCE "GRPSLCT" ;
COLOR "N/W" ;
TITLE cTITLE
REDEFINE LISTBOX oLBX FIELDS ;
oRs2:Fields("CODE"):Value, ;
oRs2:Fields("DESC"):Value, ;
oRs2:Fields("PROGID"):Value ;
HEADERS "Code", ;
"Desc", ;
"ProgID" ;
SIZES 50,170, 50 ;
ID 111 of oDlg
oLbx:bLogicLen := { || oRs2:RecordCount }
oLbx:bGoTop := { || oRs2:MoveFirst() }
oLbx:bGoBottom := { || oRs2:MoveLast() }
oLbx:bSkip := { | nSkip | Skipper( oRs2, nSkip ) }
oLbx:cAlias := "ARRAY"
REDEFINE BUTTON oBTN1 ID 112 of oDLG ;
ACTION ( zGROUP1 := oRs2:Fields("CODE"):Value, ;
oOBJ:Refresh(), ;
oDlg:END()) ;
DEFAULT
REDEFINE BUTTON oBTN2 ID 118 of oDLG ;
ACTION ( oDlg:End() )
ACTIVATE DIALOG oDlg
oDLG := NIL
oLBX := NIL
oRs2:Close()
SysReFresh()
RETURN( .T. )
//-------------------------------
STATIC FUNCTION SKIPPER( oRsx, nSkip )
LOCAL nRec := oRsx:AbsolutePosition
oRsx:Move( nSkip )
IF oRsx:EOF; oRsx:MoveLast(); ENDIF
IF oRsx:BOF; oRsx:MoveFirst(); ENDIF
RETURN( oRsx:AbsolutePosition - nRec )
// end grpslct.prg
Posted: Sat Dec 15, 2007 2:07 am
by James Bott
Rick,
>I need to be able to do something like this .. oBrow:nFreeze := 5
and ON INIT oBrow:gotocol(10)
TWbrowse has a goRight() method but no nFreeze var.
You can do this with TSBrowse.
oBrow:nFreeze:=5
for i = 1 to nCol
oBrow:goright()
next
You can get TSBrowse on my website.
TXBrowse also has nFreeze and goRight().
James
Posted: Sat Dec 15, 2007 2:10 am
by Armando
Rick:
Thank you so much.
Best regards
Posted: Sat Dec 15, 2007 9:22 am
by Enrico Maria Giordano
James Bott wrote:TWbrowse has a goRight() method but no nFreeze var.
You can do this with TSBrowse.
TCBrowse has nFreeze as well.
EMG
Posted: Sat Dec 15, 2007 10:59 am
by nageswaragunupudi
It is very simple to do with xBrowse
Code: Select all
@ 0,0 XBROWSE oBrw OF oWnd
oBrw:SetADO( oRecSet )
oBrw:CreateFromCode()
oWnd:oClient := oBrw
oBrw:nFreeze := 3
oBrw:nColSel := 8
ACTIVATE WINDOW oWnd ON INIT ( oBrw:SetFocus() )
Posted: Sat Dec 15, 2007 12:35 pm
by nageswaragunupudi
Works in Dialogs too :
Code: Select all
LOCAL oDlg, oRecSet, oBrw
oRecSet := GetRecSet()
DEFINE DIALOG oDlg SIZE 600,400 PIXEL TITLE 'XBRW ADO IN DLG'
@ 10,10 XBROWSE oBrw SIZE 280,165 PIXEL OF oDlg
// pl keep the two lines below till FWH releases their fix
oBrw:nTop := 10
oBrw:nLeft := 10
// the above two lines
oBrw:SetADO( oRecSet )
oBrw:CreateFromCode()
oBrw:nFreeze := 3
oBrw:nColSel := 6
@ 180,250 BUTTON 'Close' SIZE 40,13 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED