tstringgrid

Detecting single vs multiple selections in Delphi TStringGrid

人盡茶涼 提交于 2019-12-05 10:03:38
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 just one row, the selection.* properties do not get updated, whereas if one selects multiple rows, they

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

风格不统一 提交于 2019-12-05 06:02:45
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 data. I did find the hard coded 200 value in TBindScopeDBEnumerator.Create in the unit Data.Bind

Why InvalidateRow/InvalidateColum does not work?

若如初见. 提交于 2019-12-04 22:04:22
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 7 32 bits "SOLVED" (Delphi VCL bug) I have found that this bug exists since Delphi 1: http://qc

TStringGrid - is there a simple way to get the “current/selected” row?

左心房为你撑大大i 提交于 2019-12-04 02:52:55
问题 I can go the long way round, loop over each row, get a TRect from CellRect(col, row) , then query its State for gdSelected ... But isn't there a quicker way to get the row number of the currently selected row, if any? 回答1: .Row for selected row, .Col for selected column 回答2: Please have a look at TStringGrid.Row . 来源: https://stackoverflow.com/questions/2107683/tstringgrid-is-there-a-simple-way-to-get-the-current-selected-row

Delphi StringGrid with picture in background

怎甘沉沦 提交于 2019-12-03 21:51:44
问题 Hi does anyone know if it is possible to display a picture as a background to a string grid, Or is anyone aware of any free Grid component that can do this. Thanks colin 回答1: You could use a TDrawGrid (or a TStringGrid ), which supports owner-drawing, and do procedure TForm1.FormCreate(Sender: TObject); begin FBg := TBitmap.Create; FBg.LoadFromFile('C:\Users\Andreas Rejbrand\Pictures\Sample.bmp'); end; where FBg is a TBitmap (in the form class, for instance), and then do procedure TForm1

FillRect doesn't paint the complete TStringGrid cell in Delphi XE2

时光总嘲笑我的痴心妄想 提交于 2019-11-30 16:39:52
问题 FillRect doesn't paint the complete TStringGrid cell in Delphi XE2. There is a gap of 3 pixels on the left side in the default color (with BiDiMode set to bdLeftToRight ). This problem doesn't exist in Delphi 6 which I used before. procedure TShapeline.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin Stringgrid1.Canvas.Brush.Color:=$00FF80FF; StringGrid1.Canvas.FillRect(Rect); end; I tried to change all properties (including the DrawingStyle

Put a TCheckBox inside a TStringGrid in Delphi

夙愿已清 提交于 2019-11-28 18:27:46
I want to put a TCheckBox inside a TStringGrid in Delphi in every cell of certain column. I'm using Delphi XE. You should draw your own checkboxes, preferably using visual themes, if enabled. This is a simple sketch of how to do that: const Checked: array[1..4] of boolean = (false, true, false, true); procedure TForm4.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); const PADDING = 4; var h: HTHEME; s: TSize; r: TRect; begin if (ACol = 2) and (ARow >= 1) then begin FillRect(StringGrid1.Canvas.Handle, Rect, GetStockObject(WHITE_BRUSH)); s.cx :=

Delphi TStringGrid Flicker

笑着哭i 提交于 2019-11-28 09:18:19
I am adding multiple rows to a string grid from a CSV file @ runtime, However the StringGrid seems to flicker lots when it is being upadated, I presumed there would be a beginupadate / Endupdate command to stop this. However I cannot find it. Is there another way to stop the flicker when the grid id being updated. Colin roumen Better late than never... I use WM_SETREDRAW . For example: ... StringGrid1.Perform(WM_SETREDRAW, 0, 0); try // StringGrid1 is populated with the data here finally StringGrid1.Perform(WM_SETREDRAW, 1, 0); StringGrid1.Invalidate; // important! to force repaint after all

Put a TCheckBox inside a TStringGrid in Delphi

与世无争的帅哥 提交于 2019-11-27 11:21:40
问题 I want to put a TCheckBox inside a TStringGrid in Delphi in every cell of certain column. I'm using Delphi XE. 回答1: You should draw your own checkboxes, preferably using visual themes, if enabled. This is a simple sketch of how to do that: const Checked: array[1..4] of boolean = (false, true, false, true); procedure TForm4.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); const PADDING = 4; var h: HTHEME; s: TSize; r: TRect; begin if (ACol = 2) and

Why don't child controls of a TStringGrid work properly?

北城余情 提交于 2019-11-27 04:39:42
问题 I am placing checkboxes ( TCheckBox ) in a string grid ( TStringGrid ) in the first column. The checkboxes show fine, positioned correctly, and respond to mouse by glowing when hovering over them. When I click them, however, they do not toggle. They react to the click, and highlight, but finally, the actual Checked property does not change. What makes it more puzzling is I don't have any code changing these values once they're there, nor do I even have an OnClick event assigned to these