Listbox Freeze column and goto a column ( ADO )

Post Reply
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Listbox Freeze column and goto a column ( ADO )

Post 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
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post 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
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Post 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]
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Post by Armando »

Rick:

Thank you so much.

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post 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() )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post 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 
Regards

G. N. Rao.
Hyderabad, India
Post Reply