> Date: Sun, 25 Nov 2007 14:30:47 -0800 > From: "Alan Colburn" <[EMAIL PROTECTED]> > Subject: Highlighting Rows in dbGrid > To: "Moderated discussion list about database programming > with > Borland's Delphi" <delphi-db@elists.org> > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > I've got a DBGrid (JvDBGrid, to be precise), and I'd like > the selected row to be highlighted--while still being > editable. Any suggestions about how to do this? > > Searching myself, solutions generally seem to include > deriving another version of the grid, inside the same > unit, to allow access to protected attributes of the > class, i.e., declare something like > "THackDBGrid=class(TJvDBGrid)" in the interface, and then > add code to the OnDrawColumnCell event along the lines > of: > > //got this sample code from > http://www.delphi3000.com/articles/article_373.asp?SK= > with THackDBGrid(Sender) do > begin > if DataLink.ActiveRecord = Row - 1 then > begin > Canvas.Brush.Color := $0088FFFF; {ActiveRowColor for > MainGrid} Canvas.Font.Color := clBlack; > end > else > Canvas.Brush.Color := clWindow; {default grid color, set > in obj. inspector} DefaultDrawColumnCell(Rect, DataCol, > Column, State); end; > > For me, the only problem with this code is that I don't > have access to all "my" grid's properties. TJvDBGrid has > a WordWrap property, and I lose WordWrap with the code > above, even doing something like adding "WordWrap:=True" > to the snippet above. > > As always, thank you -- Al C. OnPaint
It's there right from TDbGrid Mick _______________________________________________ Delphi-DB mailing list Delphi-DB@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-db