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!

Multiple fields in a Grid instead of a whole Grid

Status
Not open for further replies.

sashaDG

Programmer
Jun 20, 2022
112
BY
Good afternoon, there was a question about displaying in Grid1 several fields of the SortedData cursor and not all fields of SortedData without creating a new cursor
When I write ThisForm.grid1.column3.ControlSource =[SortedData.Sklad] Nothing is displayed in Grid1
In Grid1, only ColumnCount = 5, RecordSource = 1 changed
 
You can't make a field a controlsource, the first step always is to make the workarea/alias the recordsource of the grid. But then you can reduce the columncount and make indiviual controlsources for the columns. Or design all that at design time already. That's possible even if this cursor wil only be created at runtime, you can create it once while you design the form and then design the grid that way. Just set form.binddcontrols=.f. and ensure this curosr will be there at runtime before you set form.bindcontrols=.t. or create an empty cursor which you fill with a query result by APPEND.

It's up to you to create grids at design or runtime with all these techniques in your toolkit.

Chriss
 
You say RecordSource = 1. Did you mean RecordSourceType = 1? If so, does the RecordSource contain the alias of a cursor? If so, does that cursor actually contain some data? If the RecordSource is empty, then the cursor in the current work area must contain some data. If that is not the case, the grid will be empty.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Also read up about members. The grid.memberclass and grid.memberclasslibraryy determine what column class is used to define the grid. And instead of first setting the recordsource and let the grid create as much columns as the recordsource hass, you can first set the member properties, increment the columncount by 1 and then change memeber properties again to get all individual columns you can design as necessary with controlsources and code in header click or whatever. If you only knwo grid.recordsourcetpye 1 creates a "whole grid" of the whole table/cursor, that's not reading deeper into your possibilites, it''s all described.

What I describe with columncout is not the only way, you can also use AddObject to add a column class and that incrments the column count. So no matter what exactly you already know or not, there are many ways to get to the individualisation of columns. Yet another way is to make use of the automatic all columns result and then remove individiual columns you don't want.

Chriss
 
You say RecordSource = 1. Did you mean RecordSourceType = 1? If so, does the RecordSource contain the alias of a cursor? If so, does that cursor actually contain some data? If the RecordSource is empty, then the cursor in the current work area must contain some data. If that is not the case, the grid will be empty.
I mean RecordSourceType = 1, RecordSource not contain the alias, after connecting with the alias, I can change the columns. Thanks for the replies, it's clearer
Im use ThisForm.Grid1.removeObject("Column1"), its help me
 
Good, RemoveObject works like AddObject would do when using the opposite solution. Also you can remove columns by setting columnOrder to columncount an then decrease columncount.

Chriss
 
Just to add a point ...

Whenever you make any change to the contents of the grid programmatically, you need to set focus on the grid before the changes become visible. You can do this by calling its SetFocus method. Of course, this doesn't apply in the development environment.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top