Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
If use this method for an event and put the code below from the SubRoutine in the DialogCallback Case statement, uncommenting the first line, all my rows disappear from the grid except for the first line when I click on the column header to sort:
DialogObject(TGR_Handle,co_TGR_grid,dlgobject_addevent,"HeadClick",g_HeadClick)
If use this method for an event then it works as expected:
ObjectEventAdd(grid,"HeadClick","Get_HeadClick")
#DefineSubRoutine Get_HeadClick(col_num) ; col_num = DEInfo.Parameters(1).Value gname = grid.Columns(col_num).DataField gtext = grid.Columns(col_num).Text Message(DEInfo,StrCat("g_HeadClick",@CRLF,col_num,@CRLF,grid.Columns.Count,@CRLF,gname,@CRLF,gtext)) If IsDefined(%gname%_sort_ord) Then If %gname%_sort_ord == "ASC" Then %gname%_sort_ord = "DESC" myREC.Sort = "%gname% DESC" Else %gname%_sort_ord = "ASC" myREC.Sort = "%gname% ASC" EndIf Else myREC.Sort = "%gname% ASC" %gname%_sort_ord = "ASC" EndIf #EndSubRoutineThere may be some Sort property I haven't found yet. This thing has oodles of Methods and Properties and I'm still working through them. Some things that I think would be easy are complicated (or I haven't found the right thing yet) and others are handled under Properties that seem unrelated.
The whole sort question aside I was curious why the exact same code produces different results depending on the approach taken.
Here is a code snippet of the COM EVENT:
Case msg_comevent ; ComEvent Switch(DEInfo.Identifier) Case g_HeadClick col_num = DEInfo.Parameters(1).Value gname = grid.Columns(col_num).DataField gtext = grid.Columns(col_num).Text Message(DEInfo,StrCat("g_HeadClick",@CRLF,col_num,@CRLF,grid.Columns.Count,@CRLF,gname,@CRLF,gtext)) If IsDefined(%gname%_sort_ord) Then If %gname%_sort_ord == "ASC" Then %gname%_sort_ord = "DESC" myREC.Sort = "%gname% DESC" Else %gname%_sort_ord = "ASC" myREC.Sort = "%gname% ASC" EndIf Else myREC.Sort = "%gname% ASC" %gname%_sort_ord = "ASC" EndIf Break
The dialog function tells the control to freeze other events while it is processing an event. This is the only significant difference between ObjectEventAdd and DialogObject based events.
The control decides what it wants to do when the container tells it to freeze events so there is no way to predict the behavior. In most cases the control just waits until the container is ready, but in this case the control may decide to discard any processing that has been tagged to produce an event. (Note that this explanation also assumes that the line myREC.Sort actually triggers the sort.)
I have seen this behavior with other controls that have a sort feature. If is is the case then the only alternative is to use an external subroutine to handle the "headclick" event.
Keep in mind that this is just an educated guess on my part because I have not tested the idea with this particular control, so there may be another explanation.
I am happy to continue trying things to see if we can find out what is causing this behavior but I am also happy to drop it if you are confident it is an ADO or GridControl issue. I can make it do what I need so either approach is fine.
Other than this inconvenience the TrueGrid control appears to be a nice, feature rich tool. Of course, your mileage may very.
Article ID: W16933
File Created: 2007:07:03:14:27:06
Last Updated: 2007:07:03:14:27:06