Code: TStringGrid2 = class(TStringGrid)protectedfunction DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;end;//.function TStringGrid2.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean;begin//Result:=inherited DoMouseWheel(Shift, WheelDelta, MousePos);Result:=false;end;To insert a TStringGrid2 on form, you need to do a little more tricks. You can:- Make it a new component.- TStringGrid2.Create and set its properties manually.- Draw a TStringGrid on form, and then change it to TStringGrid2. You may have to manually edit.lfm file.
![]() ![]()
Question:Can anyone point to an article or code samples anywhere on how toprovide BOTH editing AND range selection in a TStringGrid?Yes, I KNOW there are third-party grids that do this, but it'sfrustrating that the built-in grid lacks this basic capability.Background:It's pretty normal to expect to be able to both edit a cell in a grid,and also to select a range of cells such as for a Copy operation.As delivered, TStringGrid doesn't do that. It's either/or. In fact, thedocs tell us about the grid Options, 'When goEditing is included inOptions, goRangeSelect has no effect'.However, it looks like it may be possible to do editing and rangeselectsin a TStringGrid anyway!!! Through careful use of the mousedown,mouseup, selectcell and exit events, you can get dang close by switchingediting elements on and off at the right times.
But I still don't haveit perfect, and that only covers mouse use, not keyboard changes. I have not used the TStringGrid for this, so I can't provide a specific answer. But am I right in assuming you can?
Jun 28, 2011 - I am using procedure MouseMove(Shift: TShiftState; X, Y: Integer). Before setting the grid data, you disable the SelectCell event,.
That link implies it is possible even if the grid doesn't have goEditing included in its Options.
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |