Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 406 to 420 of 508, page 28 of 34
<< previous next >>
TMS IntraWeb Component Pack Pro
TTIWAdvWebGrid: How to display buttons in specific cells
TTIWAdvWebGrid: How to display buttons in specific cells
You can use the OnGetCellType event to specify the column type for a specific row, column or cell.
Example:
procedure TIWForm1.TIWAdvWebGrid1GetCellType(Sender: TObject; RowIndex, ColumnIndex: Integer; var AColumnType: TTIWColumnType; var Editor: TTIWColumnEditor; var DynEditor: TTIWDynEditType); begin if (ColumnIndex = 1) and (RowIndex = 1) then AColumnType := ctButton; end;
TDBAdvGrid
Dynamically filtering lookup datasets in a TDBAdvGrid
Dynamically filtering lookup datasets in a TDBAdvGrid
It is easy to dynamically set a filter for a lookup dataset depending on other values for a lookup editor in the TDBAdvGrid. DB fields with a lookup relatoinship are automatically edited via a combobox. To filter the values to select from, filter the lookup dataset from the OnGetEditorProp event that is triggered just before the inplace editor becomes active. Following example filter can be applied in the ADOLookup demo for TDBAdvGrid that filters the lookup dataset for countries starting with ‘S’ when there is editing on an odd row.
procedure TForm1.DBAdvGrid1GetEditorProp(Sender: TObject; ACol, ARow: Integer; AEditLink: TEditLink); begin if odd(arow) then begin adotable2.Filtered := false; adotable2.Filter := ''COUNTRY LIKE "S%"''; adotable2.Filtered := true; end else begin adotable2.Filtered := false; end; end;
TAdvStringGrid
Using NarrowDown but perform narrow down only for cells matching the search text from first character.
Using NarrowDown but perform narrow down only for cells matching the search text from first character.
To do this, set grid.NarrowDownFromStart = true.
Example:
grid.NarrowDownFromStart := true; grid.NarrowDown(‘M’);
grid.NarrowDownFromStart := false; grid.NarrowDown(‘M’);
TAdvStringGrid
Set a different XY offset for different cells in the grid
Set a different XY offset for different cells in the grid
You can change the X,Y offset dynamically for each cell via the OnGetCellColor event and call from there grid.UpdateXYOffset.
Example to set an XY offset different from the floating footer configured to display the last row of the grid:
procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow, ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont); begin if arow = advstringgrid1.RowCount - 1 then advstringgrid1.UpdateXYOffset(0,-2) else advstringgrid1.UpdateXYOffset(2,2); end;
TMS FNC UI Pack
TTMSFNCGrid: Using a TTMSFNCRichEditor as inplace editor for the TTMSFNCGrid
TTMSFNCGrid: Using a TTMSFNCRichEditor as inplace editor for the TTMSFNCGrid
It’s quite straightforward to use the TTMSFNCRichEditor as inplace editor for the grid. In the grid cell, you can display HTML formatted text and this can then be wysiwyg edited with TTMSFNCRichEditor.
All that is needed is to implement a few event handlers. Via OnGetCellEditorType, it is defined that a custom inplace editor should be used:
procedure TForm5.TMSFNCGrid1GetCellEditorType(Sender: TObject; ACol, ARow: Integer; var CellEditorType: TTMSFNCGridEditorType); begin CellEditorType:= etCustom; end;
procedure TForm5.TMSFNCGrid1GetCellEditorCustomClassType(Sender: TObject; ACol, ARow: Integer; var CellEditorCustomClassType: TTMSFNCGridEditorClass); begin CellEditorCustomClassType := TTMSFNCRichEditor; end;
procedure TForm5.TMSFNCGrid1GetCellEditorProperties(Sender: TObject; ACol, ARow: Integer; CellEditor: TWinControl); begin TMSFNCRichEditorFormatToolBar1.RichEditor := (CellEditor as TTMSFNCRichEditor); end;
procedure TForm5.TMSFNCGrid1CellEditGetData(Sender: TObject; ACol, ARow: Integer; CellEditor: TWinControl; var CellString: string); begin TMSFNCRichEditorHTMLIO1.RichEditor := (CellEditor as TTMSFNCRichEditor); TMSFNCRichEditorHTMLIO1.LoadHTML(CellString); end; procedure TForm5.TMSFNCGrid1CellEditSetData(Sender: TObject; ACol, ARow: Integer; CellEditor: TWinControl; var CellString: string); begin CellString := (CellEditor as TTMSFNCRichEditor).ContentAsHTML(''''); end;
TMS FMX UI Pack
TTMSFMXRichEditor: How to copy content from one RichEdit to another RichEdit
TTMSFMXRichEditor: How to copy content from one RichEdit to another RichEdit
It is very easy to copy the contents of a TTMSFMXRichEditor 1:1 matching to another TTMSFMXRichEditor instance with following code snippet:
var ms: TMemoryStream; begin ms := TMemoryStream.Create; try TMSFMXRichEditor1.SaveToStream(ms); ms.Position := 0; TMSFMXRichEditor2.LoadFromStream(ms); finally ms.Free; end; end;
TMS FMX UI Pack
TTMSFMXGrid: A technique to check checkboxes in the grid for specific rows by using a filter
TTMSFMXGrid: A technique to check checkboxes in the grid for specific rows by using a filter
In the TMSFMXGrid, data is loaded via a CSV file and an extra column of checkboxes is added. Now, we want to check checkboxes for specific rows and instead of looping through all rows to find the matching rows and check the checkbox, we use the built-in grid filtering capability and check only the rows that remain after filtering and then remove the filter:
var i: integer; begin TMSFMXGrid1.LoadFromCSV(''.\cars.csv''); TMSFMXGrid1.ColumnCount := TMSFMXGrid1.ColumnCount + 1; TMSFMXGrid1.AddCheckBoxColumn(TMSFMXGrid1.ColumnCount - 1); TMSFMXGrid1.Filter.Clear; TMSFMXGrid1.Filter.Add; TMSFMXGrid1.Filter.Items[0].Condition := ''BMW''; TMSFMXGrid1.Filter.Items[0].Column := 1; TMSFMXGrid1.ApplyFilter; for i := TMSFMXGrid1.FixedRows to TMSFMXGrid1.RowCount - 1 do begin TMSFMXGrid1.CheckBoxState[TMSFMXGrid1.ColumnCount - 1, TMSFMXGrid1.DisplToRealRow(i)] := true; end; TMSFMXGrid1.RemoveFilter; end;
TMS FMX UI Pack
TTMSFMXGrid: How to show/popup a comment by clicking on a cell
TTMSFMXGrid: How to show/popup a comment by clicking on a cell
To show a Popup with the cell comments you can use following code:
procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXGrid1.Comments[3, 3] := ''Hello''#13#10''World''; end; procedure TForm1.TMSFMXGrid1CellClick(Sender: TObject; ACol, ARow: Integer); var obj: TControl; begin obj := TMSFMXGrid1.GetCellObject(Cell(ACol, ARow)); if Assigned(obj) and (obj is TTMSFMXCommentGridCell) then (obj as TTMSFMXCommentGridCell).ShowPopup; end;
procedure TForm1.TMSFMXGrid1GetCellProperties(Sender: TObject; ACol, ARow: Integer; Cell: TFmxObject); begin if Cell is TTMSFMXCommentGridCell then begin (Cell as TTMSFMXCommentGridCell).CommentPanel.CalloutPosition := TCalloutPosition.Top; (Cell as TTMSFMXCommentGridCell).Popup.Placement := TPlacement.BottomCenter; (Cell as TTMSFMXCommentGridCell).CommentText.Margins.Top := (Cell as TTMSFMXCommentGridCell).CommentPanel.CalloutLength + 2; end; end;
TMS FMX Chart
Dynamically pass an array of points
Dynamically pass an array of points
With the OnGetNumberOfPoints and the OnGetPoint there is no loop necessary, the chart internally takes care of this. You only need to pass the number of points, and return the value:
procedure TForm1.TMSFMXChart1GetNumberOfPoints(Sender: TObject; ASerie: TTMSFMXChartSerie; var ANumberOfPoints: Integer); begin ANumberOfPoints := Length(ARRAY); end; procedure TForm1.TMSFMXChart1GetPoint(Sender: TObject; ASerie: TTMSFMXChartSerie; AIndex: Integer; var APoint: TTMSFMXChartPointVirtual); begin APoint.YValue := ARRAY[AIndex]; end;
TMS FMX Chart
Zooming
Zooming
The zooming functionality like in the VCL version is not implemented yet. We will add this on our feature request list, but as a starting point we have included a sample that allows you to write an own implementation. To test this code below after implementation, hold the CTRL key on the keyboard, click on the chart and drag down/right to zoom in to a specific area.
private { Private declarations } FDragArea: Boolean; FDragDownPos, FDragMovePos: TPointF; .... procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXChart1.InteractionOptions.ScaleMode := smNone; end; procedure TForm1.TMSFMXChart1AfterDrawChart(Sender: TObject; ACanvas: TCanvas; ARect: TRectF); begin if FDragArea then begin ACanvas.Fill.Color := claRed; ACanvas.FillRect(RectF(FDragDownPos.X, FDragDownPos.Y, FDragMovePos.X, FDragMovePos.Y), 0, 0, AllCorners, 0.5); end; end; procedure TForm1.TMSFMXChart1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin FDragArea := (ssCtrl in Shift); FDragDownPos := PointF(X, Y); end; procedure TForm1.TMSFMXChart1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); begin if FDragArea then begin FDragMovePos := PointF(X, Y); TMSFMXChart1.Repaint; end; end; procedure TForm1.TMSFMXChart1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); var I: Integer; begin if FDragArea then begin for I := 0 to TMSFMXChart1.Series.Count - 1 do begin TMSFMXChart1.Series[I].AutoXRange := arDisabled; TMSFMXChart1.Series[I].AutoYRange := arDisabled; TMSFMXChart1.Series[I].MinX := TMSFMXChart1.Series[I].XToValue(FDragDownPos.X); TMSFMXChart1.Series[I].MaxX := TMSFMXChart1.Series[I].XToValue(X); TMSFMXChart1.Series[I].MinY := TMSFMXChart1.Series[I].YToValue(Y); TMSFMXChart1.Series[I].MaxY := TMSFMXChart1.Series[I].YToValue(FDragDownPos.Y); end; FDragArea := False; end; end;
TMS FMX Cloud Pack
TTMSFMXPayPal: How to process a test payment
TTMSFMXPayPal: How to process a test payment
The TTMSFMXPayPal control supports the Sandbox environment from the PayPal API that allows processing test payments. Make sure the APIEnvironment property is set to peSandbox and that you are using a Sandbox account. You can find/create Sandbox accounts at the PayPal developers page.
TMS Component Pack
Delphi 10.1 Berlin Starter Edition support
Delphi 10.1 Berlin Starter Edition support
As Embarcadero disables the command-line compiling in a starter edition, our automatic installer invoking this command-line compiler cannot compile the component sources for you upon installation. Therefore, we included a project group file especially for the Delphi 10.1 Berlin Starter Edition that allows you to install the components in the IDE. After running the installer and have it extract all sources, open the group tmsdXE10startergroup.groupproj from the IDE and compile & install each package in this group from the project manager in the IDE.
TPlanner
How to create programatically a plannerItem and start an ItemEditor
How to create programatically a plannerItem and start an ItemEditor
Example:
var plit: TPlannerItem; begin plit := planner1.CreateItem; plit.itembegin := 4; plit.itemend := 6; plit.itempos := 0; plIt.Edit; end;
TAdvStringGrid
Using the OnHoverButtonsShow event to configure different hover buttons for different columns
Using the OnHoverButtonsShow event to configure different hover buttons for different columns
To do this, enable HoverButtons and implement the OnHoverButtonsRow event that is triggered when the mouse hovers a cell. Here it is possible to control whether hover buttons are shown with the Allow event parameter and from this event, the grid.HoverButtons property can be used to customize hover buttons per cell.
The code to show different hover buttons only for column 4 and 6 is therefore:
procedure TForm1.AdvStringGrid1HoverButtonsShow(Sender: TObject; X, Y: Integer; var Allow: Boolean); var c,r: integer; begin AdvStringGrid1.MouseToCell(x,y,c,r); if c = 4 then begin // configure hover buttons here for column 4 AdvStringGrid1.HoverButtons.Buttons[0].Caption := ''A''; AdvStringGrid1.HoverButtons.Buttons[1].Caption := ''B''; AdvStringGrid1.HoverButtons.Column := 4; end else if c = 6 then begin // configure hover buttons here for column 6 AdvStringGrid1.HoverButtons.Buttons[0].Caption := ''C''; AdvStringGrid1.HoverButtons.Buttons[1].Caption := ''D''; AdvStringGrid1.HoverButtons.Column := 6; end else Allow := false; end; procedure TForm1.FormCreate(Sender: TObject); begin AdvStringGrid1.HoverButtons.Enabled := true; AdvStringGrid1.HoverButtons.Buttons.Clear; AdvStringGrid1.HoverButtons.Buttons.Add.Caption := ''0''; AdvStringGrid1.HoverButtons.Buttons.Add.Caption := ''1''; AdvStringGrid1.AutoNumberRow(0); AdvStringGrid1.LinearFill(false); end;
TAdvStringGrid
Changing the font color of a part of the text in a grid cell using rich text
Changing the font color of a part of the text in a grid cell using rich text
Example:
begin AdvStringGrid1.Cells[1,1] := ''Hello world''; AdvStringGrid1.CellToRich(1,1, AdvStringGrid1.RichEdit); AdvStringGrid1.RichEdit.SelStart := 6; AdvStringGrid1.RichEdit.SelLength := 5; AdvStringGrid1.RichEdit.SelAttributes.Color := clRed; AdvStringGrid1.RichToCell(1,1, AdvStringGrid1.RichEdit); end;