tdbgrid

Delphi DBGrid alternate row colors for all DBGrids in the project

喜欢而已 提交于 2019-12-06 14:14:37
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 avoid adding the same code for each of my grids. I have like 30 grids in my project and multiplied by 13 rows of code it just adds a lot of code lines to my project making it "unfriendly". I am looking for a solution that will only add 13 lines of code to the project, not 390 lines. My formatting code looks like this (for example): procedure TDBGrid

How to get selected cells from TDBGrid in Delphi 5

跟風遠走 提交于 2019-12-06 13:30:47
问题 I have a DBGrid on a form and I have made multiple selections, I now need to send the selected cells (they are email addresses) to the "TO Box" of Outlook how can I do this, I will appreciate any help ( Delphi5) Thanks in advance 回答1: To get list of selected E-Mails you can use this procedure. For outlook you might want to use shellexec and mailto: or use API if there's any. var i: Integer; S: TStringList; begin S:=TStringList.Create; if DBGrid1.SelectedRows.Count > 0 then begin for i:=0 to

DBGrid custom draw gdRowSelected not working

半世苍凉 提交于 2019-12-06 09:27:00
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, and thus I can't tell when a row is selected. Why doesn't gdRowSelected ever apply? Is this a bug, or intentional functionality? Here's how I currently draw. When a row is selected, it should show the text in that row in the color red. procedure TForm1.gItemsDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;

Print a TDBGrid [duplicate]

可紊 提交于 2019-12-04 13:01:06
This question already has an answer here: Printing a TDBGrid 4 answers How can I print a DBGrid without installing or downloading components? OR How can I get a DBGrid's data into a RichEdit so that I can print it from there? Data aware controls get their data from DataSource property, use that. You have to manually traverse it though, no instant way possible (without third party libraries / components). You will need to be able to work out an appropriate print width for each field, something along these lines: function PrintFieldWidth(Field: TField): Integer; var CharWidth: Integer; // an

Delphi dbgrid continuous scrolling

风格不统一 提交于 2019-12-03 14:41:05
I'm making an application that holds orders and prints invoices. I have some labels, tedits, tmemos, buttons, a datasource, an adotable, a popupmenu, and a dbgrid on my form. When I build the program and scroll down the dbgrid scrollbar, it scrolls after I release mouse button. But i want continuous scrolling. Greetings Sertac Akyuz That's called thumb tracking. Derive a new class to override scrolling behavior. Example of using an interposer class: type TDBGrid = class(DBGrids.TDBGrid) private procedure WmVScroll(var Message: TWMVScroll); message WM_VSCROLL; end; TForm1 = class(TForm) DBGrid1

how can i colour whole row in DBGrid with rowselect turned off?

谁说我不能喝 提交于 2019-12-02 12:08:18
问题 RowSelect breaks the functionality of OnCellClick, so I need to turn RowSelect off. So then how can I simulate to look of row select by highlighting the all the cell of the current row? 回答1: This worked for me ( dgRowSelect=False and dgMultiSelect=False ): Declare hack types for DBGrid and GridDataLink to access protected methods and two variables type THackGrid = class(TDBGrid); THackDataLink = class(TGridDataLink); var HackGrid: THackGrid; HackDataLink: THackDataLink; In OnFormCreate assign

how can i colour whole row in DBGrid with rowselect turned off?

喜你入骨 提交于 2019-12-02 05:56:51
RowSelect breaks the functionality of OnCellClick, so I need to turn RowSelect off. So then how can I simulate to look of row select by highlighting the all the cell of the current row? This worked for me ( dgRowSelect=False and dgMultiSelect=False ): Declare hack types for DBGrid and GridDataLink to access protected methods and two variables type THackGrid = class(TDBGrid); THackDataLink = class(TGridDataLink); var HackGrid: THackGrid; HackDataLink: THackDataLink; In OnFormCreate assign the variables to have them available at drawing time: procedure TMyForm.FormCreate(Sender: TObject); begin

Set some cells in TDbGrid to editable

∥☆過路亽.° 提交于 2019-12-02 04:04:21
I want only some cells editable in a TDBGrid. In a given column, some but not all cells will be editable, so I can't just set Column.ReadOnly for the entire column and then leave it that way. What events are best to use so I can get control when a cell is entered. I might use TDbGrid.ColumnEnter to catch horizontal movement and TDataSet.AfterScroll for vertical movement in the grid. Or I could perhaps use TDBGrid.DrawColumnCell (which I'm already using to change the color of some cells...) And I'm also having trouble figuring out the best way change the read-only status of a cell. I could set

Printing a TDBGrid

£可爱£侵袭症+ 提交于 2019-12-01 09:41:53
问题 I'm working with Delphi 2009 and I really need to create a button that can print all my data in a DBGrid. I appreciate all the help I can get. 回答1: Since it is a DB grid then you can create a report using any of the report components you have, or you can do without them by using the printers unit, by iterating over the data and print them using a printer.textout 回答2: Get TxcellentFormPrinter control below and then you can print the Entire Grid. http://www.code4sale.com/joehecht/ Hope this

How do I get screen coordinates of the DBGrid cell

拥有回忆 提交于 2019-12-01 06:08:21
I want to show popup button or fancy message (with coloured background, etc) just under right-bottom corner of particular cell of the current row. For now I only figured how to get grid coordinates: x = DBGrid.DataSource.DataSet.RecNo y = DBGrid.Columns[index] There is also TCustomGrid.CellRect, which would do what I want, but it's protected and I don't want to inherit and create another component class. One crazy workaround I can think of is to save TRect-s in onDrawColumnCell event to some array. So, what do you think ? EDIT How do I get screen coordinates of, say, second cell in the current