dbgrid

How to catch scrolling event in DBGrid in Delphi

99封情书 提交于 2019-12-24 13:33:55
问题 I have a DBGrid, I need to run some code, each time the horizontal scrollbar is used. I couldn't find such event in DBGrid. Can you advise something? 回答1: Maybe this will help. It shows an example for trapping the scrolling events of a regular TStringGrid. Synchronize the Scrolling of two TStringgrids? 回答2: There is a WMHScroll procedure in TCustomGrid, but it is private. You can't use it in a DBGrid. You would have to create your own TDBGrid descendant and do your own procedure WMHScroll(var

DBGrid with read ahead capability using ADO

故事扮演 提交于 2019-12-23 20:53:19
问题 I'm working with ADO connecting to SQL Server 2005. My TADODataSet selects 1 million records. using a TDBGrid and setting the TADODataSet.CursorLocation to clUseServer works. but the TDBGrid chokes! How can I select 1 million records, avoid paging, and still be able to display records in the grid without fetching ALL records to the client side, letting the Grid read ahead as I scroll up and down? SQL enterprise manager can execute a query and select 1 million records asynchronously without

Change DBGRID row color on field value in delphi

谁说我不能喝 提交于 2019-12-23 18:26:51
问题 How to change color of dbgrid rows that have the same value on a field in delphi? for example all rows that have the same teacher note: those rows are grouped, and come after each other in dbgrid thanks in advance 回答1: You can easily implement this using the DBGrids onDrawColumnCell Event : procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if Table1.FieldByName('Teacher').AsString = 'Joe' then DBGrid1

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

蹲街弑〆低调 提交于 2019-12-22 05:02:00
问题 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

How to fix owner draw anomaly in DBGrid?

折月煮酒 提交于 2019-12-12 09:29:38
问题 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,

Delphi - Using DBGrid to select rows from a search

女生的网名这么多〃 提交于 2019-12-12 06:44:27
问题 I have searched a database using a query. The results of the search are displayed in a DBGrid component for the user to select the row s/he wishes to proceed with. DBGrid always sets the record pointer to the first record in the results set, so a row is always "selected" by default. I need to change this behaviour to no row being selected when the data is first presented so that I can determine if the user has actually made a selection. Is it possible to tell if no selection has been made, i

Delphi Dbgrid delete a record

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 03:49:35
问题 I have a multiple tabsheet. Each tabsheet in my PageControl that contain an Dbgrid with some button to manipulate this dbgrid. Sometimes, when i click on button remove, my DBGrid not change. After delete, i see my value in my DBgrid. If MyTable.recordcount > 0 then begin str := 'Value of name field/**' + MyTable.FieldByName('Name').AsString+'**/'; If Application.MessageBox(PChar(str), PChar('NAME'), MB_OKCANCEL + MB_ICONQUESTION) = IDOK then begin MyTable.Delete; end; end; I try to add

Select Multiple Rows on Shift+Click in DBGrid

筅森魡賤 提交于 2019-12-11 19:12:19
问题 I need to write the code to select multiple rows on Shift+MouseClick, so that I am able to fill down the values. Is there any way I can do it? My DBGrid options are as follows: dbGrid1.Options = [dgEditing, dgAlwaysShowEditor, dgTitles, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit, dgMultiSelect] 回答1: I originally thought that a problem you would be likely to have with this is that Shift + Click is handled by the grid itself, so the time the Grid's OnMouseUp fires, the grid

My Time Field in my DBGrid is showing the date and time instead of time only - delphi

試著忘記壹切 提交于 2019-12-11 14:17:17
问题 I have a field in my database called 'Times', it's a date/time format and its format is set to 'short time'. In my database the date does not show, nor is it being add to the database as I know. It is only the time value. My DBGrid shows the time field with the time value and the date '12/30/1899'. How do I get rid of the date in my time field. Here is the code I used to submit to the database. Get time value: bookingtimes:= timeof(dttime.Time); Submit to Database: tblbooking.FieldByName(

How do I drag and drop from a TDBGrid?

≯℡__Kan透↙ 提交于 2019-12-11 06:35:38
问题 If I set DragMode to dmAutomatic it prevents me from selecting rows. If I used OnCellClick to call BeginDrag it only fires on mouse up, which is not dragging in my opinion. If I use OnMouseDown it only fires on title row. How I am I supposed do it? 回答1: Overloading MouseDown will lead to the desired result. type TDBGrid=Class(DBGrids.TDBGrid) procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; End; TForm2 = class(TForm) ....... end; var Form2: TForm2;