dbgrid

How to set active cell in TDBGrid?

大兔子大兔子 提交于 2019-12-10 17:36:44
问题 I want to activate a cell in a TDBGrid by code. By "activate" I mean like the user clicked inside the cell, ready to edit the cell content. How could I do this? Edit: This probably involves two steps: change the currently active cell, then enter edit mode. 回答1: If you mean ‘activate the edit mode for the currently active cell’ , then you should probably do like this: MyDBGrid.EditorMode := True; Activating a particular cell can be done either via SelectedIndex : MyDBGrid.SelectedIndex := 2; {

how to color DBGrid special cell?

蹲街弑〆低调 提交于 2019-12-10 16:34:01
问题 I have a column which have only "yes" and "no" values. I want if column value is "yes" then only that cell background color is red else "no" then background color is yellow but this code colors whole row : if ADOTable1.FieldByName('Clubs').AsString = 'yes' then begin DBGrid1.Canvas.Brush.Color := clRed; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end; EDIT Thanks for your replies. My real code look like that. The "netice" column only have "L, D, W,". if Column.FieldName =

Keep the scrollbars hidden in a Delphi dbgrid (even on resize)

时光怂恿深爱的人放手 提交于 2019-12-10 03:00:47
问题 For our dbgrid we want the scrollbars to be constantly hidden. Since TDBGrid doesn't have a 'scrollbars' property, we use: ShowScrollBar(DBGrid1.Handle, SB_VERT, False); ShowScrollBar(DBGrid1.Handle, SB_HORZ, False); However when we resize the window (and the panel containing the dbgrid), for a second the scrollbars appear and becom hidden again only after recalling the two above methods. A solution is to call these methods in DrawColumnCell, but this causes flickering of the dbgrid, even

Are there any good free/cheap Delphi grid controls?

给你一囗甜甜゛ 提交于 2019-12-09 04:20:35
问题 I gave up on Delphi's DBGrid nearly a decade ago because it is simply no good. Since then, I have used Virtual TreeView which offers a lot of value but it has a few issues. Like the current state of development (e.g. None) and the fact that there is no good data-bound version. DevExpress's QuantumGrid is famous for the rich feature set but is really quite expensive. I reckon that its huge feature set is probably overkill for 95% of the general use cases for data-bound grid controls. Does

How do I do a proper owner-draw of Full Row Selected TDBGrid when TDBGrid.DefaultDrawing is false?

泄露秘密 提交于 2019-12-07 03:13:27
问题 When you have a TDBGrid, full row selection, and always show selection, even when not focused, and you want to fully owner-draw it, you have a choice of a deprecated event OnDrawDataCell , and a new event DrawColumnCell , I chose the latter and try this: procedure TDbGridTestForm.mygridDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdSelected in State then begin // mygrid.DrawCellHighlight(Rect, State, Col, Row); mygrid

How do I do a proper owner-draw of Full Row Selected TDBGrid when TDBGrid.DefaultDrawing is false?

社会主义新天地 提交于 2019-12-05 07:46:57
When you have a TDBGrid, full row selection, and always show selection, even when not focused, and you want to fully owner-draw it, you have a choice of a deprecated event OnDrawDataCell , and a new event DrawColumnCell , I chose the latter and try this: procedure TDbGridTestForm.mygridDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdSelected in State then begin // mygrid.DrawCellHighlight(Rect, State, Col, Row); mygrid.Canvas.Brush.Color := clHighlight; mygrid.Canvas.Font.Color := clHighlightText; mygrid.Canvas.FillRect

How to Format a DBGrid Column to Display Two Decimal Places? [duplicate]

感情迁移 提交于 2019-12-05 04:16:20
This question already has answers here : Setting a DBGrid column format in Delphi (3 answers) Closed 4 years ago . I would like to format specific cells to force two decimal places. The data is coming from an ElevateDB stored procedure and hooked into a TDataSource. EDIT: SQL Programming Note: I wasn't sure if this was just an ElevateDB issue or not. Before knowing about the Fields Editor , I attempted to format the data at the SQL level by using a CAST (NumericField as varchar(10)) statement inside the stored procedure. By doing so, it did not expose the DisplayFormat property inside the

How to refresh dbgrid without close and open dataset in delphi?

非 Y 不嫁゛ 提交于 2019-12-05 04:14:42
I need to refresh dbgrid constantly, in real time. Close and open dataset works fine, but blink the dbgrid. What can I do to avoid this? I'd like a solution like Ajax, that update only the necessary. Thanks Have you tried to use Disable- & EnableControls ? DataSet.DisableControls; try DataSet.Close; DataSet.Open; finally DataSet.EnableControls; end; Furthermore, it should be possible to just call DataSet.Refresh instead of closing and opening to get the same result. I use this in my app DataSet.MergeChangeLog; DataSet.ApplyUpdates(-1); DataSet.Refresh; The above code is in an action named

How to fix owner draw anomaly in DBGrid?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 20:54:04
Continuing with the project started in: How to auto fit/scale DBGrid's (or other similar) columns widths according to its contents? I used the @alzaimar answer to auto fit the columns according to their content width, but he showed me how to increase the width, but not how to decrease, so I complemented the code as shown above: procedure TRecordsBrowserFrameBase.JvDBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var h, p, g, r, w, t : Integer; const colSpc = 10; begin { ajusta as colunas de uma grade de acordo com o conteúdo

Delphi DBGrid Format Display Values

末鹿安然 提交于 2019-12-04 04:48:57
问题 I need to format values in a DBGrid to display in a certain format ex '#,##0.00' . Any idea how to do that? Regards, Pieter 回答1: Each Field in your DataSet has two events: OnGetText and OnSetText. Use event OnGetText of desired fields and use Format function to format the value using a mask. 回答2: you can use the DisplayFormat property of the field to format. check this sample TFloatField(YourDataSet.FieldByName('field')).DisplayFormat := '#,##0.00'; 来源: https://stackoverflow.com/questions