Listbox Freeze column and goto a column ( ADO )

Listbox Freeze column and goto a column ( ADO )

Postby Rick Lipkin » Fri Dec 14, 2007 6:55 pm

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: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Rick Lipkin » Fri Dec 14, 2007 7:32 pm

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

Postby Armando » Fri Dec 14, 2007 9:18 pm

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

Postby Rick Lipkin » Fri Dec 14, 2007 11:21 pm

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

Postby James Bott » Sat Dec 15, 2007 2:07 am

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

Postby Armando » Sat Dec 15, 2007 2:10 am

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

Postby Enrico Maria Giordano » Sat Dec 15, 2007 9:22 am

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
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby nageswaragunupudi » Sat Dec 15, 2007 10:59 am

It is very simple to do with xBrowse

Code: Select all  Expand view  RUN
@ 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: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Sat Dec 15, 2007 12:35 pm

Works in Dialogs too :

Code: Select all  Expand view  RUN
   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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 44 guests