tstringgrid

Delphi: StringGrid, position and Context Menu

ⅰ亾dé卋堺 提交于 2019-12-12 16:40:26
问题 I'm having a problem with using a TStringGrid and Popup menu I want to know the Row / Column of the cell that was last active when select an item from my Popup menu. However when I click on the popup menu, the StringGrid.Row is returned as -1. I've tried using MouseToCell as part of OnClick, but even after setting SG.Row it still returns as -1 in the PopUp menus routines... I suspect that the problem is the Grid losing the focus. Are there any solutions to this that don't require OnClick

Delphi XE5 Firemonkey TStringGrid OnClick event

吃可爱长大的小学妹 提交于 2019-12-12 03:39:44
问题 I have a very strange problem with Delphi Firemonkey TStringGrid on Android. It looks like that events on TStringGrid are triggered differently on windows and android platform. For example: in windows firemonkey application I have a string grid with a few columns. TStringGrid is set as read only. OnClick event I have the following code: TStringGrid(Sender).Cells[TStringGrid(Sender).ColumnIndex,TStringGrid(Sender).Selected] := 'result'; Android application has exactley the same code OnClick

TStringGrid with SpeedButtons

。_饼干妹妹 提交于 2019-12-12 02:45:02
问题 I want to have a button with icon at the end of each row. Like here: I tried this procedure TMyFrame.sgrd1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var canvas: TCanvas; sgrd: TStringGrid; point: TPoint; btn: TSpeedButton; begin sgrd := TStringGrid(Sender); canvas := sgrd.Canvas; canvas.FillRect(Rect); if (ACol = 1) then begin point := Self.ScreenToClient(ClientToScreen(Rect.TopLeft)); btn := TSpeedButton.Create(sgrd); btn.Parent := sgrd; btn.OnClick :

Setting background color of selected row on TStringGrid

北城以北 提交于 2019-12-11 03:27:34
问题 I have a TStringGrid where the selected row (max 1, no multi-select) should always have a different background colo(u)r. I set the DefaultDrawing property to false, and provide a method for the OnDrawCell event, shown below - but it is not working. I can't even describe exactly how it is not working; I supect that if I could I would already have solved the problem. Suffice it to say that instead of having complete rows all with the same background colour it is a mish-mash. Muliple rows have

How to quickly add many rows to a TStringGrid?

本秂侑毒 提交于 2019-12-10 08:09:20
问题 I googled and found a lot of advice, but it all seemed several years old and none of it helped. I have a string grid with 8 columns and once I get more than a few hundred rows it is taking over 2 seconds to populate (I compared using GetTickCount). I tried StringGrid.Perform(WM_SETREDRAW, 0, 0) (and 0, 1 at the end). I tried setting Visible := False while updating. Both to no use. There is no BeginUpdate() method. Any advice? Delphi XE2 starter. I would be willing to use a FOSS 3rd party VCL

Fixing an error in a method declaration in a form in Delphi

你。 提交于 2019-12-08 07:16:54
问题 Why am I getting this error, I replaced a stringgrid with a listview, I then set it to viewstyle vsreport but I am getting an error like (expected '=' but '(' found) its flashing on this procedure below procedure TForm2.ListView2DblClick(Sender: TObject); this is my code uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls, ComCtrls; type TForm2 = class(TForm) Edit1: TEdit; Edit2: TEdit; ListView1: TListView; ListView2: TListView; procedure

Delphi TStringGrid multi select, determining selected rows

一个人想着一个人 提交于 2019-12-07 14:16:35
问题 Is there anyway to determine which rows are currently selected in a multi-select TStringGrid , or a TCustomGrid for that matter. A property would be ideal. I know that there is the gdSelected property that gets set in the DrawCell event, procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); I can check AState for gdSelected , and keep track of this in an array somewhere, but this seems kludgey. 回答1: I guess you are talking about a range-select string grid, that is, a

How to show more than 200 rows in TStringGrid using LiveBindings?

随声附和 提交于 2019-12-07 02:50:44
问题 I have a TDataSource that is backed by a TClientDataset bound to a TStringGrid . I did this by right-clicking on the grid, selecting " Link to DB Datasource... ", and selecting the DataSource. This setup the LiveBindings for me. When I run the application, the grid only fills with 200 rows, even though there are 5000 records in the dataset. I'm unable to find any documentation regarding how to change the number of rows displayed or the proper way to allow the user to scroll through all of the

Why InvalidateRow/InvalidateColum does not work?

假如想象 提交于 2019-12-06 16:24:29
问题 InvalidateRow and InvalidateColum are not working for TStringGrid. The methods will not invalidate the entire Row/Col. InvalidateGrid always works (so this could be a dirty work-arround until the cause of the bug is found). In some circumstances (it seems to be random) InvalidateRow and InvalidateColum seem to work also. Update: I have found which circumstances will trigger the bug: the grid must be larger than the visible area and the position is outside of the view. Any ideas? Delphi 7, Win

OnDrawCell Center Text StringGrid - Delphi

一曲冷凌霜 提交于 2019-12-06 06:41:37
I'm trying to get the text in my StringGrid to center. After some research I came up with this function posted by someone else here that when used on DefaultDraw:False should work. procedure TForm1.StringGrid2DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var S: string; SavedAlign: word; begin if ACol = 1 then begin // ACol is zero based S := StringGrid1.Cells[ACol, ARow]; // cell contents SavedAlign := SetTextAlign(StringGrid1.Canvas.Handle, TA_CENTER); StringGrid1.Canvas.TextRect(Rect, Rect.Left + (Rect.Right - Rect.Left) div 2, Rect.Top + 2, S);