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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a method a runtime !!!

Status
Not open for further replies.

ChrisAgius

Programmer
Sep 27, 2000
51
MT
I have this form with a grid. I have set the font of the grid headers which are indexed to bold. I have a problem now. I need to pass a code in the Click of the Header so that when the user clicks on the header the table will change the index to that header. So in other words my only problem is to pass this command "Thisform.IndexOrder.ChangeOrder(This)" to the click of the headers.

Can you help ???
Thanks
 
Hi!

It seems this is a good time to learn teh DEFINE CLASS... ENDDEFINE commands structure to define classes. You can define this way a custom header class with the code in CLICK event:

Code:
DEFINE CLASS MyHeader AS Header
  Procedure Click
    Thisform.IndexOrder.ChangeOrder(This)
  ENDPROC
ENDDEFINE

Than replace default header with your custom header:

Code:
for i=1 to Grid.ColumnCount
  Grid.Columns(i).AddObject('Header2','MyHeader')
  Grid.Columns(i).Header2.Name = Header1
endfor

Note that Previous header removed automatically by VFP once add new header. Than you can rename the new header so name will match with defaut name (Header1).

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

Do not understand what you meant here...

Well, you can define a code for existing method in VFP using DEFINE CLASS and than bind that code to the existing object in run-time (Late binding); however, I connot re-post it here because that method is not invented by me. I saw it discussed at the Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
What is the problem with writting whatever code you want in the Click event of each Header?? Do I miss something here?! Walid Magd
Engwam@Hotmail.com
 
Walid, when you create grid in run-time, or change grid columns in run-time, you require to have some way to define that code in run-time.
Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Vlad

I suspect the thread title "Writing a method a runtime !!!" is misleading.

As I read it, Chris is not creating this grid in runtime and all he needs, as Walid also suspects, is some code in the .Click event of the header.

FAQ184-446 gives such an example, allowing the user to select the appropriate index and toggle between ascending and descending order.

Chris :)
 
Hi!

I always thought it is better to make it more generic. If you have 10 grids, each with 5-10 columns, imagine changing of the Click of headers 50-100 times. It is depended on many things, really.

I answered that way just because:
1. In original post Chris already have a program that change indexes
2. Font is set in run-time. I think so because next statements show that the topic is about making changes in grid (adding a code) in run-time.

Anyway, I cannot be always correct ;-), sorry if something wrong.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
No nothing you told me is wrong .... that was exactly what i wanted. It worked perfectly by changing the class of the header at runtime. Thanks a lot to you all .... especially to TomasDill.

Regards,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top