tstringgrid

delphi TStringGrid and right mouse button

南楼画角 提交于 2021-02-05 11:12:31
问题 I am using Delphi 10.1 Berlin to make a Multi-Device application. I have a TStringGrid in order to list some data from a query. I also have a popup menu (edit, delete, ...), but in order to edit/delete an item I have to click on a cell using the left mouse button. Is it possible to "select a row" using only the right button before showing the popup menu? I tried: procedure TForm1.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button =

How to fill cell of a string grid using custom color?

让人想犯罪 __ 提交于 2020-05-23 10:56:13
问题 I am trying to write custom date picker(calendar). The dates will be displayed on the stringgrid. I am trying to fill the clicked cell with a custom color and make that selected celltext bold. Here is my code: type TStringGrid = Class(Vcl.Grids.TStringGrid) private FHideFocusRect: Boolean; protected Procedure Paint;override; public Property HideFocusRect:Boolean Read FHideFocusRect Write FHideFocusRect; End; TfrmNepaliCalendar = class(TForm) ... ... ... end; procedure TfrmNepaliCalendar

list all files from a directory in a string grid with delphi

三世轮回 提交于 2020-01-06 02:59:10
问题 I am working with Delphi 7 and I would like to list all the files in a given directory in a string grid (one file per row and all in 1 column). I have searched for about an hour now and cannot find any examples on how to do this so any help you can provide would be appreciated. 回答1: This will fill a TStrings descendant (eg., TStringList , TMemo.Lihes , and so forth) with all of the files in a specified folder: function GetFiles(const StartDir: String; const List: TStrings): Boolean; var SRec:

OnDrawCell Center Text StringGrid - Delphi

≡放荡痞女 提交于 2020-01-02 10:33:12
问题 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);

OnDrawCell Center Text StringGrid - Delphi

≯℡__Kan透↙ 提交于 2020-01-02 10:32:11
问题 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);

Change text size in Firemonkey StringGrid

一世执手 提交于 2019-12-30 11:38:28
问题 How to change text size in stringgrid header? 回答1: You could write an OnApplyStyleLookup event handler similar to this: procedure TForm1.StringGrid1ApplyStyleLookup(Sender: TObject); var Header: THeader; I: Integer; begin Header := THeader((Sender as TStringGrid).FindStyleResource('header')); if Assigned(Header) then begin for I := 0 to Header.Count - 1 do with Header.Items[I].Font do begin Size := 32; Style := [TFontStyle.fsBold]; end; Header.Height := 48; end; TStringGrid(Sender).Realign;

How To Toggle The cell Colour And Text In A TStringGrid On And Off

橙三吉。 提交于 2019-12-23 18:26:01
问题 I am running Lazarus v0.9.30 (32 bit compiler). I have a TForm with a standard TStringGrid on it. The grid has the following properties set. RowCount = 5, ColumnCount = 5, FixedCols = 0, FixedRows = 0. I Googled some code that showed me how to change the cell colour and add some text to the cell when a user clicks on a TStringGrid cell. All works fine and I have extended it slightly to toggle the color/text on and off on the GridClick event. The questions I have are more to better understand

Firemonkey MouseToCell equivalent

与世无争的帅哥 提交于 2019-12-22 08:08:16
问题 In Delphi VCL if I wanted to see which cell (column and row) of a TStringGrid my mouse was hovering over I'd use MouseToCell. This method is no longer in Delphi (XE2) for FireMonkey apps. Does anyone know how I can determine the cell my mouse is over? OnMouseMove has X & Y values but these are screen coordinates and not cell coordinates. Many thanks. 回答1: There's actually a MouseToCell method in TCustomGrid , which the StringGrid descends, but it's private. Looking at its source, it makes use

Detecting single vs multiple selections in Delphi TStringGrid

自闭症网瘾萝莉.ら 提交于 2019-12-22 06:24:59
问题 This is a follow up to my previous question Delphi TStringGrid multi select, determining selected rows regarding Delphi String Grids. It's a different question. I was looking more closely at the ONSelectCell Event TSelectCellEvent = procedure (Sender: TObject; ACol, ARow: Longint; var CanSelect: Boolean) of object; I noticed that the TStringGrid.Selection.Top,Bottom properties are not necessarily accurate (within the event itself). Basically, if someone goes from selecting multiple rows to

How can you change the text orientation in cells in the fixed rows in a Delphi TStringGrid

别说谁变了你拦得住时间么 提交于 2019-12-17 20:46:53
问题 I have a standard TStringGrid on a form. I have one Fixed Row in the grid that contains a number of columns, which are all TGridColumns objects. I have set the column titles using the object inspector and the default orientation is horizontal. Is there any way you can make the orientation vertical (like you can in cells in Excel)? 回答1: Here's how to render the first row's text vertically in Lazarus: unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls,