>>>I've got a grid object in a container that only has 1 column in it.
>>>During program execution, I dynamically add columns to the grid with the AddObject method. Everything works fine, but I would like to allow the user to right-click or double-click in the text boxes in the grid. I've placed wait windows in the right-click and double-click events of the grid, and they never fire.
>>>
>>>Now for something even more interesting.
>>>
>>>I created a class called "blah" that was based on the TextBox control. In this new class, I added wait windows in the double-click and right-click events of the "blah" class. In my program I cycle through all of the columns that I'm adding to the grid, and do a RemoveObject("Text1") to remove the TextBox control that is placed there by default, then then AddObject("Text1", "blah") to add in my custom version of the TextBox control.
>>>
>>>Now when I run my program, I can't see the data in any cell that I click in, and I can't use the arrow keys to navigate through the grid.
>>>All the data is displayed in the grid properly, but it just vansihes when I click in it, and reappears when I move to another cell.
>>>
>>>I want to be able to double-click or right-click in a cell so that I can do other stuff based on the value of the cell.
>>>
>>>Does anyone have any ideas?
>>>
>>>Thanks,
>>>Jeff Newbill
>>
>>Basically, you did everything right, but, unfortunately, it seems that grid gets corrupted somewhere in the middle. You know, grids used to be corrupted when there are too many on-fly re-buildings. IMO, the better way to have a solid grid is to create it in form designer as a first place and permannently base on read/write cursor. Then, whatever interface solutions you want to apply to this grid, it will be actually repopulating (DELETE/ZAP/INSERT) of this cursor.
>
>That's a good point. It certainly would save a lot of headaches when the Grid suddenly de-stabilizes for no known reason. A full rebuild with identical code fixes. Having some kind of data driven grid builder is an excellent idea. Do you think that control sources should only be placed programatically/run time not design time?.
I don't want to say that this is the only way, but it's really safe way. However, I didn't mean that column.controlsources or grid.recordsources should be changed literally in run-time. Grid and their columns will be always based on the same cursor.fields, but record contents of this cursor might change.
Edward Pikman
Independent Consultant