Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resetting grids
Message
From
10/11/1998 16:37:49
 
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00156378
Message ID:
00156408
Views:
54
>>>>>>>In my grid class, I put code to set up the grid according to saved settings:
>>>>>>>
>>>>>>>
>>>>>>>      RESTORE FROM MEMO Settings ADDITIVE
>>>>>>>      THIS.RecordSource = THIS.RecordSource
>>>>>>>      FOR i = 1 TO THIS.ColumnCount
>>>>>>>         THIS.Columns[i].Header1.Caption = laSets[i,1]
>>>>>>>         THIS.Columns[i].ControlSource = laSets[i,2]
>>>>>>>         THIS.Columns[i].Width = laSets[i,3]
>>>>>>>         THIS.Columns[i].ColumnOrder = laSets[i,4]
>>>>>>>      ENDFOR
>>>>>>>
>>>>>>>
>>>>>>>For the most part this works, but there's one problem. Comboboxes in the grid don't initialize. I have the cbo rowsource as an SQL statement and the rstype as SQL. When I don't have this code in the grid, the combobox opens a table and creates a cursor and populates itself. With the code, it doesn't do any of that.
>>>>>>>
>>>>>>>I've narrowed it down to it being setting the controlsource that's causing this. Without that line, the cbos work. Unfortunately, without that line the columns have no control sources.
>>>>>>>
>>>>>>>Any idea what I can do to make this work?
>>>>>>>
>>>>>>>Thanks,
>>>>>>>
>>>>>>>-Michelle
>>>>>>
>>>>>>How big is grid.recordsource (i mean number of records)?
>>>>>
>>>>>About 7 right now. Just test data.
>>>>>
>>>>>-Michelle
>>>>
>>>>No, I'm asking about real size. Also, what is this, view or cursor?
>>>
>>>It's a view. You mean what size will it be with real data? Probably not more than a thousand records.
>>>
>>>Thanks,
>>>
>>>-Michelle
>>
>>AFAIK, view doesn't require GRID.Recordsource=Grid.Recordsource line. If you cannot remove this line then you have two alternatives: either enforce combo by Column.RemoveObject/AddObject (combo should be instanciated from class with needed code in Combo.Init event), or populate grid from read-write cursor which takes data from your view (here you don't need in restoring grid settings).
>
>I don't know if it's required; I just figured better safe than sorry. The grid doesn't know if it's source is a view, table, or cursor.
>
>Actually, there's a third workaround that's not so complicated. I just have to move the SQL to the init of the combobox. I was just hoping there was a way to fix it in the grid class so I don't have to put that restriction on the comboboxes.
>
>Oh well, can't win 'em all. :)
>
>Thanks for your help.
>
>-Michelle

Michelle, when you override grid.recordsource you kill all specific grid settings including all combo (and other column.controls) altogether. This is the reason of your problem. I don't think it's reasonable to force grid class to accomodate both view and cursor, because the abovementioned problem related to cursors only (in most cases, at least) and requires specific (again for cursors only) workaround (this workaround usually allows to exclude cumbersome restoring of grid's settings).
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform