Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 5 of 5 total |
Some Questions About TGrid |
Thu, Feb 1 2018 6:21 PM | Permanent Link |
Frederick Chin | Hi,
With EWB 2.06b11, is it possible for TGrid to have:- 1. Incremental searching - While in a column, I would like to position the cursor to the first row matching the typed characters 2. Alternate row colours - How do I apply different colours to odd and even rows? -- Frederick |
Sat, Feb 3 2018 9:51 PM | Permanent Link |
erickengelke | Frederick Chin wrote: >With EWB 2.06b11, is it possible for TGrid to have:- > >1. Incremental searching - While in a column, I would like to position the cursor to the first row matching the typed >characters Yes, in the KeyUp (ie. after the key is processed) of the TEdit, scan the TDataSet for the first matching row. > 2. Alternate row colours - How do I apply different colours to odd and even rows? I think I documented TGrid background colours in my EWB book. I use it in some projects but don't remember offhand. Erick http://www.erickengelke.com |
Sun, Feb 4 2018 5:20 PM | Permanent Link |
Frederick Chin | erickengelke wrote:
/* Yes, in the KeyUp (ie. after the key is processed) of the TEdit, scan the TDataSet for the first matching row. */ I am not using a TEdit. It is purely the TGrid's cursor location. /* I think I documented TGrid background colours in my EWB book. I use it in some projects but don't remember offhand. */ Why don't you create a component set based on your book and sell it rather than the book? -- Frederick |
Sun, Feb 4 2018 9:07 PM | Permanent Link |
Raul Team Elevate | On 2/1/2018 6:21 PM, Frederick Chin wrote:
> With EWB 2.06b11, is it possible for TGrid to have:- > 1. Incremental searching - While in a column, I would like to position the cursor to the first row matching the typed characters Have not done it myself but should be relatively straightforward though you have to build most of the logic yourself. KeyPress event of the grid would give you the key user pressed - if you want to support more than 1 character search then you would need to buffer it (in a string for example). As each key is pressed you can do a quick search of the grid data and set current location to the row matching the typed info > 2. Alternate row colours - How do I apply different colours to odd and even rows? > Easiest is to use the OnCellUpdate event for the column (you do need to set this event for each column but you can assign exact same procedure). Something like this (though i suggest pick better colors procedure TForm1.GridColumnCellUpdate(Sender: TObject; ACell:TGridCell); begin //alternate columns based on the index if ACell.index mod 2 = 0 then ACell.Background.Fill.Color := clLightGreen else ACell.Background.Fill.Color := clLightBlue; end; Raul |
Tue, Feb 6 2018 5:56 PM | Permanent Link |
Frederick Chin | Raul,
/* Have not done it myself but should be relatively straightforward though you have to build most of the logic yourself. KeyPress event of the grid would give you the key user pressed - if you want to support more than 1 character search then you would need to buffer it (in a string for example). As each key is pressed you can do a quick search of the grid data and set current location to the row matching the typed info */ Thanks. This will be a good start for me to work on. /* Easiest is to use the OnCellUpdate event for the column (you do need to set this event for each column but you can assign exact same procedure). Something like this (though i suggest pick better colors procedure TForm1.GridColumnCellUpdate(Sender: TObject; ACell:TGridCell); begin //alternate columns based on the index if ACell.index mod 2 = 0 then ACell.Background.Fill.Color := clLightGreen else ACell.Background.Fill.Color := clLightBlue; end; */ I had to add a check for the InterfaceState of the cell to check if the cell is focused and a cell font colour so that the content could be seen as follows:- procedure TForm1.GridColumnCellUpdate(Sender: TObject; ACell:TGridCell); begin //alternate columns based on the index if ACell.index mod 2 = 0 then begin if SameText(ACell.InterfaceState,BOTH_STATE_NAME) then begin ACell.Background.Fill.Color := clLightGreen; ACell.Font.Color:= clBlack; end; end else begin if SameText(ACell.InterfaceState,BOTH_STATE_NAME) then begin ACell.Background.Fill.Color := clBlack; ACell.Font.Color:= clLightGreen; end; end else begin if SameText(ACell.InterfaceState,BOTH_STATE_NAME) then begin ACell.Background.Fill.Color := clLightBlue; ACell.Font.Color:=clBlack; end else begin if SameText(ACell.InterfaceState,BOTH_STATE_NAME) then begin ACell.Background.Fill.Color := clBlack; ACell.Font.Color:=clLightBlue; end end end; end; I am not sure why I had to use BOTH_STATE_NAME (through experimentation) instead of FOCUSED_STATE_NAME as there doesn't seem to be documentation for the State Names. Thanks for pointing me in the right direction. -- Frederick |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |