Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to re-create all columns in grid
Message
From
22/09/2001 05:13:07
 
 
To
21/09/2001 14:23:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00556193
Message ID:
00559609
Views:
38
Hi!

If you can package it and send it to me, I will look to it and try to figure out where is a problem...

>I checked it and found that _vfp.autoyield is .t.
>I don't have any _vfp.autoyield assignments in my program.
>
>>Dooh! Check what is the value of _VFP.AutoYield. I will not wonder of it is .F. When you do a lot of actions with grid, there are certain events generated by VFP that are put into the events queue. If _VFP.AutoYield is .F., these events will not be processed between VFP code lines and thus will wait until some events processing loop is not reached (in your case it is READ EVENTS). Using DOEVENTS at some moment in the process of grid columns layout changing could help, also setting of _VFP.AutoYield temporarily to .T. can help too. If crash will happen again, at least you will be able to figure out exactly after WHAT actions crash appears by using DOEVENTS command in several places of that program.
>>
>>
>>>The exact line number reported from C5 dialogue is a line
>>>
>>>READ EVENTS
>>>
>>>in main program. This is problably because I call method by defining a key label in menu bar.
>>>Calling this method from from keypress event returns some other line number.
>>>Calling from keypress method (I defined a key ctrl+q to call it) causes C5 error
>>>rarely. Today I was unable to get C5 using the code below. However, I need
>>>to call this code using a key label defined as menu hotkey in menu designer.
>>>In previous test, calling this method from keypress shows .columncount=0
>>>or removeobject line in C5 message box.
>>>
>>>I tested disabling grid visibility with the following code but it still causes C5 after a number of repated calls (holding down and releasing F3 key) to this method. Disabling grid visibility also causes bad form flash effect.
>>>
>>>>Also, when you remove last column, what grid looks like - did you tried to stop program at that moment and see what happens with grid? Try before removing the last column from grid add a single column to it.
>>>
>>>I haved tried those since I swithed back to .columncount=0
>>>destroy method.
>>>
>>>
>>>* Comple form ChangeInputform() method code.
>>>if !this.ActiveControlValid()
>>>  return .f.
>>>  endif
>>>this.MousePointer = 11
>>>_screen.mousepointer = 11
>>>this.gridbase1.visible = .f.
>>>this.cmdFormSwitch1.setfocus()
>>>this.gridbase1.columncount = 0
>>>this.cmdFormSwitch1.FindNextLayout(thisform.brtabel)
>>>this.gridbase1.Init()
>>>this.gridbase1.setfocus()
>>>this.mousepointer = 0
>>>_screen.mousepointer = 0
>>>this.gridbase1.visible = .t.
>>>
>>>
>>>>What is the exact code line that cause the C5 Error?
>>>>Did you tried to set Grid.Visible = .F. before this process?
>>>>
>>>>Also, when you remove last column, what grid looks like - did you tried to stop program at that moment and see what happens with grid? Try before removing the last column from grid add a single column to it.
>>>>
>>>>>I tried the following code but still go C5
>>>>>
>>>>>
>>>>>this.cmdFormSwitch1.setfocus()
>>>>>crrecords = this.gridbase1.recordsource
>>>>>this.gridbase1.recordsource = ''
>>>>>LOCAL lnCount, lnI
>>>>>lnCount = ThisForm.Gridbase1.ColumnCount
>>>>> FOR lnI = lnCount TO 1 STEP -1
>>>>>    with eval("thisform.Gridbase1.Columns(lni)." + thisform.Gridbase1.Columns(lni).CurrentControl)
>>>>>      .Visible = .F.
>>>>>    endwith
>>>>>  ThisForm.GridBase1.RemoveObject(ThisForm.GridBase1.Columns(lni).Name)
>>>>>  ENDfor
>>>>>this.cmdFormSwitch1.FindNextLayout(thisform.brtabel)
>>>>>this.gridbase1.recordsource = crrecords
>>>>>this.gridbase1.Init()
>>>>>this.gridbase1.setfocus()
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>Then, you can remove comboboxes before you change the grid columns. Something like
>>>>>>
>>>>>>for i=1 to grid.ColumnCount
>>>>>>  if eval("Grid.Columns(i)." + Grid.Columns(i).CurrentControl+ ".BaseClass") == "ComboBox"
>>>>>>    with eval("Grid.Columns(i)." + Grid.Columns(i).CurrentControl
>>>>>>      .Visible = .F.
>>>>>>    endwith
>>>>>>    Grid.Columns(i).RemoveObject(Grid.Columns(i).CurrentControl)
>>>>>>  endif
>>>>>>endfor
>>>>>>
>>>>>>
>>>>>>BTW, just an idea - did you tried to set the Visible = .F. for grid for the moment when you change its columns? Try this simple idea and let us know if it helped.
>>>>>>
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform