Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Clicking on a Read-Only Grid?

Status
Not open for further replies.

andyk

Programmer
Jul 29, 2000
24
GB
Hi,

I have a grid which is populated and all cells are read-only. I would like to be able to double click on one of the rows and active a 'details' form for that row.

Obviously, the cells of the grid being disabled results in the Click/Double Click events being inactive. Any ideas??

Many Thanks,

Andy :)
 
Do following:

Make grid controls as read-only, not as disabled
To hide cursor use SET CURSOR OFF in each control's GotFocus or When event. SET CURSOR ON in LostFocus or Valid event.
Make background color for selected text and normal text teh same.
Remove frame from textboxes.
Adjust margin property of textboxes.

This way all events will work, but controls will lokk the same when focused and not focused.


Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Thanks Vlad,

I've managed to get it working to a fashion. Your suggestion of turning the cursor OFF and ON seems to have no affect though. Also I am using the DynamicBackColor property, consequently the Selected Color needs to change according to the expression in the DynamicBackGround property. I tried changing the SelectedBackColor in the GotFocus to no avale.

I can live with these minor blemishes though, so thanks alot for your suggestions.

Cheers Andy.
 
You could change the selectedBackColor in the interactiveChange event if your control was NOT read only. You might consider allowing the user to type, but undoing it in the VALID event

Something like...

VALID EVENT
cOldValue = this.value
this.text = cOldValue
RETURN .T.

Or something like that. Good Luck


-Pete
 
I always used that way and it worked. With highlighting, together with SET CURSOR OFF change also back color. Try to play around this more accurately.

You can also use the transparent cover for grid, but this might be more complex and requires some programming.

Good luck!

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hi,

This is the class definition I use for highlighting my grids and making them readonly. When you want to make a form appear in the click event of the grid and or cell (control) you will have to add this to the click event of the control.

The lockscreen property is used to make it possible only to use lockscreen when the user clicked on the grid and starts scrolling, otherwise lockscreen is not necessary.

The SET CURSOR OFF setting works, but shows the cursor just for an instance and then dissappears.

**************************************************
*-- Class: grd_base (d:\cbproject\libs\base_cntrl.vcx)
*-- ParentClass: grid
*-- BaseClass: grid
*-- Time Stamp: 11/24/00 09:51:11 PM
*
#INCLUDE "d:\cbproject\include\app.h"
*
DEFINE CLASS grd_base AS grid


FontName = "MS Sans Serif"
DeleteMark = .F.
GridLines = 2
Height = 200
ReadOnly = .T.
RecordMark = .F.
Width = 320
GridLineColor = RGB(192,192,192)
*-- Stores te current record number of the record source.
rec_no = 0
Name = "grd_base"

*-- Indicates if highlighting should be.
lnohighlight = .F.

*-- Stores a logical indicating if the lockscreen should be used when scrolling.
PROTECTED luselockscreen


PROCEDURE BeforeRowColChange
LPARAMETERS nColIndex
LOCAL llRetVal
IF THIS.lUseLockScreen
THISFORM.LockScreen = .T.
ENDIF

ENDPROC


PROCEDURE Valid
LOCAL llRetVal
llRetVal = DODEFAULT()
IF llRetVal
THIS.lUseLockScreen = .F.
THISFORM.LOCKSCREEN = .F.
SET CURSOR ON
ENDIF

RETURN llRetVal
ENDPROC


PROCEDURE When
LOCAL llRetVal
llRetVal = DODEFAULT()
IF llRetVal
THIS.lUseLockScreen = .T.
THISFORM.LOCKSCREEN = .F.
SET CURSOR OFF
ENDIF

RETURN llRetVal
ENDPROC


PROCEDURE Refresh
DODEFAULT()

THIS.rec_no = RECNO(THIS.RECORDSOURCE)
ENDPROC


PROCEDURE AfterRowColChange
LPARAMETERS nColIndex
LOCAL llRetVal
llRetVal = DODEFAULT(nColIndex)

IF llRetVal
THIS.rec_no = RECNO(THIS.RECORDSOURCE)
ENDIF

IF THIS.luseLockScreen
THISFORM.LOCKSCREEN = .F.
ENDIF

RETURN llRetVal
ENDPROC


PROCEDURE Init
LOCAL llRetVal, lnCounter

llRetVal = DODEFAULT()

IF llRetVal AND !(THIS.lNoHighLight)
THIS.SETALL("DynamicBackColor", "IIF(RECNO(THIS.RecordSource) = THIS.rec_no, 8388608, 16777215)", "Column")
THIS.SETALL("DynamicForeColor", "IIF(RECNO(THIS.RecordSource)= THIS.rec_no, 16777215, 0)", "Column")
IF THIS.COLUMNCOUNT > 0
FOR lnCounter = 1 TO THIS.COLUMNCOUNT
WITH THIS.COLUMNS[lnCounter]
.Text1.BACKCOLOR = 8388608
.Text1.FORECOLOR = 16777215
.Text1.DISABLEDFORECOLOR = 8421504
.Text1.DISABLEDBACKCOLOR = 16777215
ENDWITH
ENDFOR
ENDIF
ENDIF

RETURN llRetVal
ENDPROC

ENDDEFINE
*
*-- EndDefine: grd_base
************************************************** Weedz (The Grassman)
veld4663@exact.nl

'It never hurts to help...' - Eek the cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top