TDBGrid is a VCL control used to display and manipulate records from a TDataset in a tabular fashioned way. It is defined in DbGrids.pas unit.
Questions tagged [tdbgrid]
156 questions
3
votes
2 answers
How to get the text under the cursor in a TDbGrid
Screen width is just not enough to display some text fields. I don't know how to auto-wrap them and I doubt that it can be easily done.
So, I thought that I would do something like
procedure TForm1.FormMouseMove(Sender: TObject;
Shift:…

Mawg says reinstate Monica
- 38,334
- 103
- 306
- 551
3
votes
3 answers
Delphi grid with a different data type in each row, displayed dynamically
I am trying to create a Delphi grid to allow display and edit in a db grid of data that might have a different data type on each row. I would like to display a specific control for each data type, e.g. when the data type is DateTime, I want to…

John Marquez
- 71
- 4
2
votes
1 answer
How to get row number in OnDrawColumnCell event?
This is how my drawing routine for TDBGrid component looks like. I am replacing values from database based on some rules:
void __fastcall TForm_Loadpoint_Details::DBGrid1DrawColumnCell(
TObject *Sender, const TRect &Rect, int DataCol, TColumn…

truthseeker
- 1,220
- 4
- 25
- 58
2
votes
1 answer
Updating a grid after changes have been made
Right, this is probably going to be pretty simple. I have a form that contains a grid, if you select one of the records and press 'Edit' you get taken to another form where you can edit the data attached to that record - this all works.
However upon…
user863551
2
votes
2 answers
TDBGrid: OnDrawColumnCell Data is overlapping
I am working on Delphi 10.2 and SQL Server 2008.
I have to modify some value in TDBGrid. when I modify the value using OnDrawColumnCell Data is getting over lapped when I click on that column and the same is working fine in Delphi 7.
Example…

DelphiLearner
- 489
- 6
- 25
2
votes
1 answer
How to draw an empty cell using TDBGrid?
I'm trying to display an empty text for a TDBGrid's cell without changing the field's value neither the backcolor of the cell.
I'm not sure it's the right approach but I've tried using the OnDrawDataCell event as follows:
procedure…

Fabrizio
- 7,603
- 6
- 44
- 104
2
votes
1 answer
Delphi DBGrid showing compressed rows
I am having the strangest of issues with Delphi's DBGrid.
I noticed that Sometimes, and I mean only sometimes (It is completely random) when I load rows into a delphi DBGrid, the grid does not show the data.
It instead shows a couple of compressed…

Marcel
- 874
- 1
- 14
- 28
2
votes
1 answer
Simulate mouse click on a cell in TDBGrid
How can simulate a mouse click on some cell in TDBGrid?

userPro
- 59
- 4
- 12
2
votes
1 answer
Delphi : Avoid editing a column in TDBgrid
I know that using a column's readonly property, i can avoid editing its field value. But this doesn't stop the inplace editor to show itself.
I need a way to make the column not only protected but "untouchable".
Is there a way, please ?

JimPapas
- 715
- 2
- 12
- 27
2
votes
2 answers
Delphi ClientDataSet Sorting by changing IndexName
I've been learning about the ClientDataSet in delphi and how it can help sort my SQL database. The data is showing fine in my TDBGrid and i've enabled sorting by clicking on a header by changing the IndexField of the ClientDataset. I want to make it…

Toby Fox
- 105
- 4
- 11
2
votes
1 answer
How can I get column's caption in TDBGrid?
How can I get column's caption in TDBGrid?
I've tried this but it returns FieldName instead caption:
DBGrid.Fields[i].DisplayLabel

Dmitry
- 14,306
- 23
- 105
- 189
2
votes
2 answers
Delphi DBGrid alternate row colors for all DBGrids in the project
How can I make all my grids look the same way all over my forms?
I want to implement an alternate row color that must be applied on all grids of my project. Is it possible without adding the same DrawColumnCell event code for every grid?
I want to…

user1137313
- 2,390
- 9
- 44
- 91
2
votes
1 answer
How to **FIX** a value to the DBGrid's header heigth?
When the user selects the header of my grid, I would like to bold the column header of the grid.
I use the following code to achieve this:
procedure TForm1.DBGrid1TitleClick(Column: TColumn);
var I: Integer;
begin
//Prevent multiple clicks!
…

EProgrammerNotFound
- 2,403
- 4
- 28
- 59
2
votes
0 answers
DBGrid custom draw gdRowSelected not working
I'm custom drawing in a DBGrid by monitoring OnDrawColumnCell to color the column. When I read the event handler's State, I successfully capture gdSelected and color the font in the selected cell. But when I monitor gdRowSelected, it's never there,…

Jerry Dodge
- 26,858
- 31
- 155
- 327
2
votes
0 answers
How to detect if column was moved?
I'm sorting a TDBGrid using it's OnTitleClick event, but I don't want to sort the grid when the user just arranges his columns.
Is it possible to detect if the column was moved / is moving when the OnTitleClick event fires?
OnStartDrag is not fired,…

Jens Mühlenhoff
- 14,565
- 6
- 56
- 113