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

Help with my first grid.

Status
Not open for further replies.

MikeL91

Programmer
Feb 8, 2001
100
US
Is there a sample, FAQ, or something that shows a simple form where the user choses a path & dbf file, and then it populates a data grid on the form for him.


I can easily use the wizzard to create a grid & bind it to an existing table, but I want it to be dynamic for whatever dbf file is chosen (in whatever layout)

Thanks
-Mike
 
The most basic requirement is to set the RecordSource.
You can change it on the fly by issuing a command something like this:
Code:
STORE Getfile("DBF", "Choose a table") TO cTable
Thisform.Grid1.Recordsource = cTable
Now when you start customizing things, that becomse a whole 'nuther critter.

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Mike,
Couldn't agree more with you there! I find that the forms that are designed to do "everything" are the forms that never get used...


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
I think I understand what you mean. You are talking about creating the form & grid from scratch in the code & populating it all at run time correct? I have 2 questions, Do you have any examples of that? I saw one on MSDN that I think was close to that, but can not seem to find it now.

Also, if I have code sitting behind other command button on the current form, is there a way to create a class from those & add them to the code that creats the form & grid?

I just added the command buttons to my form and in the code section of the click event put my program code.

Thanks Again,
Mike
 

You are talking about creating the form & grid from scratch in the code & populating it all at run time correct?

Not necessarily in the code, and not necessarily from scratch.

Just subclass the grid class (and other controls you use, including forms and command buttons you mention), put all the functionality/appearance you need to be common in there, then use this class to create your custom grids/forms/buttons wherever you need them, visually or in code.
 

Mike,

One other thing you might care to try:

- Open a new form in the form designer;

- Open the project manager; click on any of your tables.

- Drag the table to the form in the form designer.

The result is one ready-made grid, complete with columns, RecordSource and ControlSources.

Mike.


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top