Vladimir Shevchenko, January 1, 2001
One of my clients wants to have a smart grid class. Among other cool features this class should be able to remove the columns from the grid on the fly. Basically, the user will click the right button over the grid and choose from popup menu the Remove current column option. I said, "No problem, Sir"...
One of my clients wants to have a smart grid class. Among other cool features this class should be able to remove the columns from the grid on the fly. Basically, the user will click the right button over the grid and choose from popup menu the Remove current column option. I said, "No problem, Sir" and went to my computer to see what I have to do. The first thing that I saw was DeleteColumn method in grid class.
This method has one parameter called nIndex that refers to Column's index inside the Grid. So, my first implementation of this method was like the following code:
) and then the timer releases itself. Simple? I thought, yes.
I rewrote the cf_RemoveCurrentColumn method in order to use the ColumnDestroyer control:
Procedure cf_RemoveCurrentColumn
* Method for removing the current column
local inNextColumn, inCurrColumn, icName, icGrid,icCmd
inCurrColumn = this.ActiveColumn && obtain a number of active column
* Which column should be activated? if we stay on the last column then
* the focus will move to the first column
inNextColumn = iif(inCurrColumn < this.ColumnCount,inCurrColumn+1, 1)
icName = upper(this.Columns(this.ActiveColumn).Name) && name of active column
* Move focus to the next cell in a row
this.ActivateCell(this.ActiveRow,inNextColumn)
* Take the grid hierarchy
icGrid = sys(1272,this)
* Make the string with appropriate call
icCmd = alltrim(icGrid)+[.DeleteColumn(]+alltr(str(inCurrColumn))+[)]
* Instantiate the timer that will do the rest
if icName <> [MARKROW]
* You can't delete the mark column
* Instantiate the Column destroyer that will do the rest
=thisform.Addobject([tmr_DestroyColumn],[cls_ColumnDestroyer],icCmd)
endif
Endproc
In conclusion I would like to say that in any case you should avoid releasing container's or class members from inside of container because it could give you just dangerous results.
P.S. Excuse me for possible errors, after all, English isn't my mother tongue
Vladimir ShevchenkoVladimir Shevchenko is an experienced independent software developer with 10 years of experience. Started to work with Foxpro since its DOS version thru all Windows version up to current release of VFP. Worked as employee at government institutions like Central bank of Russia and then started independent consulting for companies around the world in 1997. Developed many projects using various tools like frameworks, report generators, Active X components and have clear ability to translate user requirement specifications into software design and coding schedules. Talented in designing clear, concise and easy-to-understand user interfaces.
More articles from this author
Vladimir Shevchenko, January 1, 2001
Let assume that you live anywhere around the globe and want to develop an application with multilanguage support. It does not matter where do you live: Russia, USA, Canada, Switzerland etc, because you will always get the same problems with localization of user interfaces. Nowadays, you have differ...