Re: grid column header click code (vfp6)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



what i do with memo field is to create an index out of the keywords found in
it... i will eliminate articles, prepositions, pronouns and the like that i
find deemed not necessary or qualify as keyword, then i store them on a
separate table with the keyfield as pointer to the original table... this
will be helpful also if the user wants to find some 'keywords' contained in
the memo field, which is faster based on my experience.

"John Davy" wrote:

Thanks Dan

I hadn't seen that trick before (but you can just index on memofield + " ")
but in any case it would be appropriate given the multiline detail stored
in them to use these fields this way in my app

Cheers
John


"Dan Freeman" <spam@xxxxxxxxxxxxx> wrote in message
news:uxNIh%23cgHHA.2332@xxxxxxxxxxxxxxxxxxxxxxx
You can index memo fields! You just need to make sure the expression
evaluates to a fixed length.

INDEX ON PADR(memofield,100)

Dan


"John Davy" <nospm_jdavy@xxxxxxxxxxx> wrote in message
news:%23EMC4PWgHHA.596@xxxxxxxxxxxxxxxxxxxxxxx
Thanks Dan

Yes, that is just what I did - I already had a grid subclass that I
wanted to use
Alan's code is a bit more generic for those who may have headers not
named 'Header1'

I couldn't follow the need for the gnModule code - I suspect he has taken
this from some code where a global variable was set to indicate that the
header click was to be executed - so I didn't use it.

The form works a treat - I added properties to the column for IndexTag,
HeaderCaption, SortDirection and DataType
The column object gets passed to the form procedure GridHeaderClick()
when a header is clicked
In this I can test to see which way the column was last sorted (asending
or descending and toggle the direction)
After setting the order, I reset all column headers back to the default
stored in each column's HeaderCaption
then I append a + or - to the HeaderCaption of the one just sorted.
Then I go to the top of the table, refresh the grid and set focus back to
the sorted column
(otherwise the focus returns to column 1 and this looks ugly when sorting
columns to the right of the table beyond the standard view)
Columns with a DataType of 'M' can't be indexed without appending a
string to them - for my application they are ignored.

Cheers
John



"Dan Freeman" <spam@xxxxxxxxxxxxx> wrote in message
news:OsEvQhQgHHA.3372@xxxxxxxxxxxxxxxxxxxxxxx
You don't actually *need* to subclass the grid itself. Just the header
will do.

With TheGrid
For lnCount = 1 to .ColumnCount
* Yank out the "stock" header and put in one of your own
.Columns(lnCount).Removeobject("Header1")
.Columns(lnCount).Addobject("Myheader","MyHeaderClass")
Endfor
Endwith

An easier way, though, would be using BindEvents so the header delegates
its click to some other object's method.

Dan

"John Davy" <nospm_jdavy@xxxxxxxxxxx> wrote in message
news:eQBqoDLgHHA.2640@xxxxxxxxxxxxxxxxxxxxxxx
Thanks Alan - I will give this a go

Cheers,
John

"Allan" <Allan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3545EA8F-44D2-4694-B931-28A1894FA203@xxxxxxxxxxxxxxxx
Hi John,

You have to sub-class your grid and header using codes. Try the
following:

*-- store in a prg called 'MYGRID.PRG'
*-- class for the custom grid
DEFINE CLASS grdGeneric AS Grid

PROCEDURE Init
FOR EACH oColumn IN This.Columns
FOR EACH oControl IN oColumn.Controls
IF UPPER(oControl.BaseClass) = "HEADER"
cHdrName = oControl.Name
cCaption = oControl.Caption
oColumn.RemoveObject(cHdrName)
oColumn.NewObject(cHdrName, "hdrCustom")
oColumn.&cHdrName..Caption = cCaption
ENDIF
ENDFOR
ENDFOR
ENDPROC

ENDDEFINE

*-- class for the custom header
DEFINE CLASS hdrCustom AS Header

PROCEDURE Click
IF TYPE('gnModule') <> 'N'
gnModule = 0
ENDIF

DO CASE
CASE gnModule = 1 && Do your code

OTHERWISE
=MESSAGEBOX('Current Column: ' + This.Parent.Name + CHR(13) + ;
'Current Header: ' + This.Caption)
ENDCASE
RETURN
ENDDEFINE

*-- Usage in the Form INIT event:
SET PROCEDURE TO MYGRID.PRG ADDITIVE

This.AddObject('myGrid','grdGeneric')

This.myGrid.RecordSource = "yourCursor"
This.myGrid.Top = 1
This.myGrid.Left = 1
This.myGrid.Height = This.Height - 5
This.myGrid.Width = This.Width - 5
This.myGrid.Visible = .T.

*-- Take note that the 'gnModule' variable can be a public one that
will
*-- tell how will you handle the sorting or other things you want when
the
Click
*-- event of the custom header is fired out...

hope this will help...

Allan

"John Davy" wrote:

I am doing something similar to Ch Loftberg
I have a generic select form that will display a number of different
tables
aand allow for the user to select a row to be passed bak to the
calling
procedure.
In order to overcome grid reconstruction problems I create the grid
in the
form init using addobject() and set the recordsource to the required
table
at that time.

I was hoping to allow the user to sort by a selected column by
clicking on
the column header
Is there a way of inserting code into the column header click event
at
runtime?

Regards
John Davy














.



Relevant Pages

  • Re: Grid Column Header
    ... So now I must now create a PRG file just to ... the grid on the fly, or to predefine your grid class using code in the ... You can change the header class used in the Init of the grid. ... ENDFUNC ...
    (microsoft.public.fox.vfp.forms)
  • Re: Grid Column Header
    ... grid on the fly, or to predefine your grid class using code in the headers. ... You can change the header class used in the Init of the grid. ... INSERT INTO somedata VALUES ... ENDFUNC ...
    (microsoft.public.fox.vfp.forms)
  • Re: Grid Column Header
    ... have a custom grid class with that header code in it. ... ENDFUNC ...
    (microsoft.public.fox.vfp.forms)
  • Re: custom columns/headers
    ... I am specifying that a grid should use my column class which should use my ... taking your tack - how do dynamic header captions ever get assigned using ... >> header classes that we can derive from are not the same as the ...
    (microsoft.public.fox.programmer.exchange)
  • Member classes (Grids, Columns & Headers)
    ... Grid class (which uses the Member class feature for mapping Columns) ... Column class in a PRG (which uses the HeaderClass for mapping Header ...
    (microsoft.public.fox.programmer.exchange)